代码在这里:
from multiprocessing import pool
def worker(num):
print 'Worker:', num
return
if __name__ == '__main__':
jobs = []
for i in range(5):
p = multiprocessing.Process(target=worker, args=(i,))
jobs.append(p)
p.start()
Run Code Online (Sandbox Code Playgroud)
对不起,我是python的新手。每当我尝试导入池时,我都会收到以下错误。它说 os.chdir(wdir) 有问题,但我不知道是什么。有什么帮助吗?
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\z080302\Desktop\WinPython-32bit-2.7.6.3\python-2.7.6\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 540, in runfile
execfile(filename, namespace)
File "C:/Users/z080302/Desktop/Python_Projects/mp_test.py", line 18, in <module>
p = multiprocessing.Process(target=worker, args=(i,))
NameError: name 'multiprocessing' is not defined
Run Code Online (Sandbox Code Playgroud)