windows os.fork(), AttributeError: module 'os' has no attribute 'fork'

xiaoxiao2025-10-26  11

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))

https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/001431927781401bb47ccf187b24c3b955157bb12c5882d000

 

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'

 

转载请注明原文地址: https://www.6miu.com/read-5038545.html

最新回复(0)