AttributeError: module 'os' has no attribute 'fork'
import os
print('Process (%s) start...' % os.getpid())
# Only works on Unix/Linux/Mac:
pid = os.fork() #不要在windows系统中使用,会出错,
if pid == 0:
print('I am child process (%s) and my parent is %s.' % (os.getpid(), os.getppid()))
else:
print('I (%s) just created a child process (%s).' % (os.getpid(), pid))
os.fork()方法,使用在linux /Unix系统,不在windows下使用,如果在windows下使用,报错;
Process (21132) start...
Traceback (most recent call last):
File "E:/soft/pycharm/workplace/1.py", line 5, in <module>
pid = os.fork()
AttributeError: module 'os' has no attribute 'fork'