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:
#...