正如您在下面看到的,我在Linux (RHEL)上运行Python2.6,但由于某些原因,它没有os.O_EXLOCK。有什么原因吗?有没有办法绕过这个问题呢?
Python 2.6.5 (r265:79063, Apr 9 2010, 11:16:46)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.O_EXLOCK
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'O_EXLOCK'
>>> os.O_DSYNC
4096
>>>
发布于 2012-08-23 09:39:11
如在the Python Standard Library documentation中所指出的,
以下常量是open()函数的标志参数的选项。它们可以使用按位OR运算符|组合在一起。其中一些并不是在所有平台上都可用。有关它们的可用性和用途的说明,请参阅Unix上的open(2)手册页或Windows上的MSDN。
O_EXLOCK
originated in the BSD world;它在Linux上通常不可用。您也许能够改用Python fcntl
module。
https://stackoverflow.com/questions/12083536
复制相似问题