美文网首页
python ValueError: too many valu

python ValueError: too many valu

作者: 11的雾 | 来源:发表于2018-10-12 13:13 被阅读0次

一般情况下这种情况出现在字典中,如下:

a_dict = {'name':'levin','job':'teacher'}
for k,v in a_dict:
... print k,v
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: too many values to unpack
正确写法:
a_dict = {'name':'levin', 'job' : 'teacher'}
for k,v in a_dict.items():
print k,v

相关文章

网友评论

      本文标题:python ValueError: too many valu

      本文链接:https://www.haomeiwen.com/subject/xvawaftx.html