這裏是我的功能:的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