7.10,由于某种原因,以下代码片段正在产生错误......
device_info = {'username': 'test', 'password': 'test', 'appliance': 'name', 'hostname': 'hostname', 'prodcut': 'juice'}
print "{} {} {} {} {}".format(**device_info)
这引发了一个异常:
Traceback (most recent call last):
File "python", line 4, in <module>
print "{} {} {} {} {}".format(**device_info)
IndexError: tuple index out of range
我相信这段代码在语法上应该是正确的,但是,我似乎无法解压缩我的 dict 以传递给任何函数,不知道为什么这不起作用。