os.stat怎么成了python的内建函数呢?
2012-08-02 22:10
369 查看
lib/os.py中没有找到os.stat函数,在python解释器环境中,显示os.stat为python内建函数
os模块里没有stat的定义,stat是由平台依赖的 posix 、nt等内建模块提供的,看一下os模块的最开头部分。
def _get_exports_list(module):
try:
return list(module.__all__)
except AttributeError:
return [n for n in dir(module) if n[0] != '_']
if 'posix' in _names:
.......
import posix
__all__.extend(_get_exports_list(posix))
.......
elif 'nt' in _names:
.......
import nt
__all__.extend(_get_exports_list(nt))
.......
参考:http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=3762715&pid=22230940&page=1&extra=#pid22230940
http://topic.csdn.net/u/20120801/22/19a5750a-37e2-4440-910b-05c88183be31.html?seed=304111345&r=79293043#r_79293043
>>> os.stat <built-in function stat>
os模块里没有stat的定义,stat是由平台依赖的 posix 、nt等内建模块提供的,看一下os模块的最开头部分。
r"""OS routines for Mac, NT, or Posix depending on what system we're on. This exports: - all functions from posix, nt, os2, or ce, e.g. unlink, stat, etc. - os.path is one of the modules posixpath, or ntpath - os.name is 'posix', 'nt', 'os2', 'ce' or 'riscos' - os.curdir is a string representing the current directory ('.' or ':') - os.pardir is a string representing the parent directory ('..' or '::') - os.sep is the (or a most common) pathname separator ('/' or ':' or '\\') - os.extsep is the extension separator ('.' or '/') - os.altsep is the alternate pathname separator (None or '/') - os.pathsep is the component separator used in $PATH etc - os.linesep is the line separator in text files ('\r' or '\n' or '\r\n') - os.defpath is the default search path for executables - os.devnull is the file path of the null device ('/dev/null', etc.) Programs that import and use 'os' stand a better chance of being portable between different platforms. Of course, they must then only use functions that are defined by all platforms (e.g., unlink and opendir), and leave all pathname manipulation to os.path (e.g., split and join). """
def _get_exports_list(module):
try:
return list(module.__all__)
except AttributeError:
return [n for n in dir(module) if n[0] != '_']
if 'posix' in _names:
.......
import posix
__all__.extend(_get_exports_list(posix))
.......
elif 'nt' in _names:
.......
import nt
__all__.extend(_get_exports_list(nt))
.......
参考:http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=3762715&pid=22230940&page=1&extra=#pid22230940
http://topic.csdn.net/u/20120801/22/19a5750a-37e2-4440-910b-05c88183be31.html?seed=304111345&r=79293043#r_79293043
相关文章推荐
- Python OS/OS.PATH/Built-in 常用函数
- Python借助os.system,subprocess.call()函数调用系统命令
- Python里的OS模块常用函数说明
- python os.path模块函数中文说明
- python的函数怎么使用传递引用的方式
- Python os.getcwd()函数的实际应用方案介绍
- PYthon os.path 访问函数
- Python里的OS模块常用函数说明
- 【python】如何批量读取文件夹的所有文件数据,os模块与open函数结合使用实例
- Python模块函数:os.listdir 打印Win7目录中的文件-中文乱码问题
- 纠结的Python2.7编码与os.walk()函数的目录参数
- python 中的split()函数和os.path.split()函数
- python中os.mkdir()函数
- PYthon os.path 访问函数
- Python里的OS模块常用函数说明
- 【python】os和os.path模块及其常用函数方法
- python内置模块[sys,os,os.path,stat]
- python中os模块的常见处理函数
- python os.exec*()家族函数的用法
- os、os.path 模块中关于文件、目录常用的函数使用方法(python)