Python:"import posix"问题 [英] Python: "import posix" question
问题描述
如果导入os
模块,则可以运行以下命令来推断os.py的位置
If I import os
module, I can run the following to infer the location of os.py
>>> import os
>>> print os.__file__
/usr/lib/python2.6/os.pyc
但是,当我导入posix
时,它没有__file__
属性.是因为它是在python运行时的一部分而不是在标准库中实现的?
However, when I import posix
, it does not have the __file__
attribute. Is it because it is implemented as a part of the python runtime, not as a standard library?
我如何仅使用python官方文档就能找到更多类似的信息?
How can I find out more information like this using solely the python official documentation?
推荐答案
这是一个C模块.它既可以内置到Python二进制文件中,也可以编译为共享库.在您的情况下,它是在
It's a C module. It can be either built into the Python binary or compiled as a shared library. In your case it is compiled in
官方文档说不要直接导入它,您应该使用该功能通过os
The official docs say not to import it directly, and you should use the functionality provided via os
这篇关于Python:"import posix"问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!