File and Directory Access文件和目录访问¶
The modules described in this chapter deal with disk files and directories. 本章介绍的模块处理磁盘文件和目录。For example, there are modules for reading the properties of files, manipulating paths in a portable way, and creating temporary files. 例如,有用于读取文件属性、以可移植方式操纵路径和创建临时文件的模块。The full list of modules in this chapter is:本章模块的完整列表如下:
pathlib
—Object-oriented filesystem paths面向对象的文件系统路径os.path
—Common pathname manipulations常用路径名操作fileinput
—Iterate over lines from multiple input streams迭代来自多个输入流的行stat
—Interpreting解释stat()
resultsstat()
结果filecmp
—File and Directory Comparisons文件和目录比较tempfile
—Generate temporary files and directories生成临时文件和目录glob
—Unix style pathname pattern expansionUnix样式路径名模式扩展fnmatch
—Unix filename pattern matchingUnix文件名模式匹配linecache
—Random access to text lines随机访问文本行shutil
—High-level file operations高级文件操作
See also参阅
Module模块os
Operating system interfaces, including functions to work with files at a lower level than Python file objects.操作系统接口,包括用于在低于Python文件对象的级别上处理文件的函数。Module模块io
Python’s built-in I/O library, including both abstract classes and some concrete classes such as file I/O.Python的内置I/O库,包括抽象类和一些具体类,如文件I/O。Built-in function内置功能open()
The standard way to open files for reading and writing with Python.用Python打开文件进行读写的标准方法。