使用操作系统模块的chflags或distutils模块的dir\u util会导致AttributeError(在*nix平台上运行时)

2024-10-01 02:27:53 发布

您现在位置:Python中文网/ 问答频道 /正文

Python documentation表示os.chflags存在。你知道吗

但是,在*nix平台上执行以下代码会导致AttributeError

>>> import os
>>> os.chflags
AttributeError: module 'os' has no attribute 'chflags'

同样distutils.dir_utildocumented here也会导致AttributeError。你知道吗


Tags: no代码importosdocumentationdirnixattribute
2条回答

可能只是因为您的系统没有为chflags提供系统调用。
这也是我运行mint18.1的情况,我得到的结果和你一样,对于python2和python3。你知道吗

BSD系统提供此功能,而其他系统不一定提供此功能。你知道吗

我的python3.6.7也遇到了同样的问题。在我的ubuntu18.04盒子里。 它在https://bugs.python.org/issue31313中提到。 简而言之,Linux不支持chflags。
Linux使用chattr,遗憾的是Python操作系统模块没有

相关问题 更多 >