系统出现异常: too many values to unpack (expected 2)

时间:2022-10-25 02:02:29

先感谢[ValueError: too many values to unpack](http://leonzhan.iteye.com/blog/1720315)
系统出现异常:打开太多值(预期2)
这种错误是指一个tuple值赋给一个tuple变量时,变量个数不够。如:a,b = (1,2,3)
for example: if ditc_a is dict, following code will get this error
for key, value in ditc_a:
...

Correct:
for key, value in ditc_a.items():
于是我在原代码上添加 'items()',如下:

> for temp_name_interface,condition in temp_moduel_execute.items():

---
后记:这个代码最先是iteritems(),后面运行报错,我就把iteritems(),改成了items(),还报错,我就把items()给去掉了,于是出现标题中错误。恩,转了一圈又回来了。