![](/img/trans.png)
[英]How can I implement a control function in my program and avoid the AttributeError: 'module' object has no attribute error
[英]I'm getting AttributeError: 'module' object has no attribute 'fork' when i run my program on windows. How can i fix this?
我尝试在parent()
函数中调用os.fork()
,但它给了我同样的错误。
这是我的代码:
import os
def child():
print('Hello from child', os.getpid())
os._exit(0) # else goes back to parent loop
def parent():
while True:
newpid = os.fork()
if newpid == 0:
child()
else:
print('Hello from parent', os.getpid(), newpid)
if input() == 'q': break
parent()
os.fork()
仅在Unix中可用。 看到这个 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.