天天看点

[报错] TypeError: run() argument after * must be an iterable, not int[报错] TypeError: run() argument after * must be an iterable, not int问题描述:报错原因:解决办法:

[报错] TypeError: run() argument after * must be an iterable, not int

问题描述:

在多线程操作,调用threading.Thread 报错,TypeError: run() argument after * must be an iterable, not int

import threading


def run(n):
    print("run the thread:",n)


num = 0
th1 = threading.Thread(target=run, args=(1))
th1.start()
           

报错:

TypeError: run() argument after * must be an iterable, not int

报错原因:

解决办法:

import threading


def run(n):
    print("run the thread:",n)


num = 0
th1 = threading.Thread(target=run, args=(1,))  # 在参数1 后面加一个, 即可解决异常;
th1.start()
           

继续阅读