这里是我的功能:的Python:迭代通过一本字典给我“int对象不是可迭代”
def printSubnetCountList(countList):
print type(countList)
for k, v in countList:
if value:
print "Subnet %d: %d" % key, value
下面是当函数调用传递给它的字典中的输出:
<type 'dict'>
Traceback (most recent call last):
File "compareScans.py", line 81, in <module>
printSubnetCountList(subnetCountOld)
File "compareScans.py", line 70, in printSubnetCountList
for k, v in countList:
TypeError: 'int' object is not iterable
有任何想法吗?
这么简单,但工作。谢谢! – Dan 2011-04-21 23:04:43