我试图在函数中创建一个线程,但收到一个错误
这是我的密码:
from threading import Thread
def threadFunction(parameter):
print(parameter)
def main():
parameter = "abc"
t = Thread(target='threadFunction', args=(parameter, ))
t.start()
t.join()
main()
我收到以下错误:
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Users\tom\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "C:\Users\tom\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
TypeError: 'str' object is not callable
没有引用。传递函数值本身,而不是与在源代码中定义时拼写相同的字符串
相关问题 更多 >
编程相关推荐