10. 文件和目录访问¶
本章中描述的模块处理磁盘文件和目录。 例如,有一些模块用于读取文件的属性,以可移植的方式操作路径以及创建临时文件。 本章的完整模块列表如下:
- 10.1.
os.path— 常见路径操作 - 10.2.
fileinput— 迭代来自多个输入流的行 - 10.3.
stat— 解析stat()结果 - 10.4.
statvfs— Constants used withos.statvfs() - 10.5.
filecmp— 文件及目录的比较 - 10.6.
tempfile— 生成临时文件和目录 - 10.7.
glob— Unix 风格路径名模式扩展 - 10.8.
fnmatch— Unix 文件名模式匹配 - 10.9.
linecache— 随机读写文本行 - 10.10.
shutil— 高阶文件操作 - 10.11.
dircache— Cached directory listings - 10.12.
macpath— Mac OS 9 路径操作函数
参见
- Section File Objects
A description of Python’s built-in file objects.
- 模块
os Operating system interfaces, including functions to work with files at a lower level than the built-in file object.
