TypeError:*之后的start()参数必须是可迭代的,而不是int

时间:2019-06-11 13:54:38

标签: python pyqt

我想在线程中运行一些计时器,但显示错误TypeError: start() argument after * must be an iterable, not int,我该如何解决?

    while 1:
            try:
                _thread.start_new_thread(self.timer0.start,100)
                _thread.start_new_thread(self.timer1.start,150)
                _thread.start_new_thread(self.timer2.start,200)
                _thread.start_new_thread(self.timer3.start,250)
                _thread.start_new_thread(self.timer4.start,300)
                break
            except:
                print ("Error: unable to start thread")
            break

1 个答案:

答案 0 :(得分:4)

检查文档: https://docs.python.org/3/library/_thread.html

  

_thread.start_new_thread(函数,args [,kwargs])

     

启动一个新线程并返回其标识符。线程使用参数列表args(必须为元组)执行function函数。

因此,正确的呼叫如下:

_thread.start_new_thread(self.timer0.start, (100,))