类型错误:'长' 对象不可迭代

2024-06-25 22:43:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我刚刚用python创建了一个字典。

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

当我想为每组运行tread函数时

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

我得到以下错误:

TypeError: 'long' object is not iterable

那么,我怎样才能解决这个问题呢?


Tags: thenoselfinfooutput字典typegroup
1条回答
网友
1楼 · 发布于 2024-06-25 22:43:24

尝试stb_info.items()。只是在dict上迭代它的键,所以它试图将一个键(长的)解包成两部分,这是不可能的。

相关问题 更多 >