Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python在字典中循环:TypeError:unpack non-sequence sub={} 对于a,b在sub:#_Python_Dictionary - Fatal编程技术网

Python在字典中循环:TypeError:unpack non-sequence sub={} 对于a,b在sub:#

Python在字典中循环:TypeError:unpack non-sequence sub={} 对于a,b在sub:#,python,dictionary,Python,Dictionary,中,您正在寻找这个吗 sub = {} for a, b in sub: #<--- error occurs here for s in b: #do blah. I was told a b is a list 做 尝试将(a,b)分配给子项中可能不是序列的键。是否正在查找此项 sub = {} for a, b in sub: #<--- error occurs here

中,您正在寻找这个吗

sub = {} 
for a, b in sub:                   #<--- error occurs here
   for s in b:
       #do blah. I was told a b is a list


尝试将
(a,b)
分配给
子项中可能不是序列的键。

是否正在查找此项

sub = {} 
for a, b in sub:                   #<--- error occurs here
   for s in b:
       #do blah. I was told a b is a list


尝试将
(a,b)
分配给
子项中可能不是序列的键。

在可能的情况下使用:)是。grrr当时我看的教程是错误的……iteritems()和items()之间有什么区别吗?
iteritems()
返回一个迭代器,您使用的是哪个Python版本?@ealeon:然后使用
iteritems()
。在可能的情况下使用:)是的。grrr当时我看的教程是错误的……iteritems()和items()之间有什么区别吗?
iteritems()
返回一个迭代器,您使用的是哪个Python版本?@ealeon:然后使用
iteritems()
for a, b in sub:
    #...