关于 AttributeError: module 'os' has no attribute 'fork' 问题

本文探讨了Python中os模块的fork函数在不同操作系统上的表现。在Windows系统上尝试调用该函数会引发AttributeError异常,而在Linux系统上则可以正常工作。文章强调了os.fork在Windows系统上的不适用性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Windows:

Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import os
>>> os.fork

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    os.fork
AttributeError: 'module' object has no attribute 'fork'
 
Linux:

$ python
Python 2.7.8 (default, Jul  4 2014, 13:08:34) 
[GCC 4.9.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.fork
<built-in function fork>
>>> 

os.fork  不要在windows系统上用





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值