2016-11-17 39 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