10. 文件和目录访问¶
本章中描述的模块处理磁盘文件和目录。 例如,有一些模块用于读取文件的属性,以可移植的方式操作路径以及创建临时文件。 本章的完整模块列表如下:
- 10.1.
os.path— 常见路径操作 - 10.2.
fileinput— Iterate over lines from multiple input streams - 10.3.
stat— Interpretingstat()results - 10.4.
statvfs— Constants used withos.statvfs() - 10.5.
filecmp— File and Directory Comparisons - 10.6.
tempfile— Generate temporary files and directories - 10.7.
glob— Unix style pathname pattern expansion - 10.8.
fnmatch— Unix filename pattern matching - 10.9.
linecache— Random access to text lines - 10.10.
shutil— High-level file operations - 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.
