Python错误集锦:开启线程时提示TypeError: func() argument after * must be an iterable, not int

博客围绕Python开启线程时出现的TypeError错误展开。错误提示为func()参数必须是可迭代对象而非整数,可能原因是使用threading.Thread()创建线程时,args参数传递未用元组。解决方法是改用元组传递参数,且单个参数时后面要加逗号。

 

原文链接:http://www.juzicode.com/archives/2756

错误提示:

开启线程时提示TypeError: func() argument after * must be an iterable, not int

#juzicode.com/vx:桔子code
import  threading
def func(para1):
    print(para1)
if __name__ == '__main__':
    para1 =11
    t0 = threading.Thread(target=func, name='func-0',args=(para1))
    t0.start()
Exception in thread func-0:
Traceback (most recent call last):
  File "d:\python\python38\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "d:\python\python38\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
TypeError: func() argument after * must be an iterable, not int

 

可能原因:

1、使用threading.Thread()创建线程时,args参数传递的是一个元组,即使这个时候函数只有1个参数

评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值