我想做一个简易的多线程来运行一些cmd命令,但是总是报一个很玄学的错误。
import threading
import os
class RUN:
def unit(data):
data = os.popen(str(data))
data = data.read()
print(data)
def RUN(data):
print(data)
name_list = []
theard = threading.Thread(target=RUN.unit,args=(data))
theard.start()
print(theard)
theard.join()
print(theard)
报错如下
Exception in thread Thread-1 (unit):
<Thread(Thread-1 (unit), started 3388)>
Traceback (most recent call last):
File "F:\main_file\main\python-3-11-1\Lib\threading.py", line 1038, in _bootstrap_inner
self.run()
File "F:\main_file\main\python-3-11-1\Lib\threading.py", line 975, in run
self._target(*self._args, **self._kwargs)
TypeError: RUN.unit() takes 1 positional argument but 8 were given
<Thread(Thread-1 (unit), stopped 3388)>