类型错误:“长"对象不可迭代 [英] TypeError: 'long' object is not iterable

查看:45
本文介绍了类型错误:“长"对象不可迭代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在 python 中创建了一个字典.

I have just created a dictionary in python.

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

当我想为每个组运行我的踏板功能时

When I want to run my tread function for each group

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

我收到以下错误:

TypeError: 'long' object is not iterable

那么,我该如何解决这个错误?

So, how I can solve this bug?

推荐答案

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

Try stb_info.items(). Just iterating over a dict iterates over its keys, so it's trying to unpack a key (a long) into two parts, which isn't possible.

这篇关于类型错误:“长"对象不可迭代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆