2016-11-17 40 views
1

我剛剛在python中創建了一本字典。TypeError:'long'對象不可迭代

stb_info = self.stb_type() 
print type(stb_info) #The output gives me dict 

當我想運行我的胎面功能爲每個組

for group_no, shelves in stb_info: 
    self.thread_function(group_no, shelves) 

我收到以下錯誤:

TypeError: 'long' object is not iterable 

所以,我怎麼能解決這個bug?

回答

5

嘗試stb_info.items()。只是遍歷一個dict迭代它的關鍵字,所以它試圖將一個關鍵字(長整數)解包爲兩部分,這是不可能的。

+1

或'.iteritems()'因爲它是Python 2.x. – katrielalex