Python logo

上一主题

operator --- 标准运算符对应函数

下一主题

pathlib --- 面向对象的文件系统路径

当前页

  • 报告 Bug
  • 显示源码

导航

  • 索引
  • 模块 |
  • 下一页 |
  • 上一页 |
  • Python logo
  • Python »
  • 3.12.4 Documentation »
  • Python 标准库 »
  • 文件和目录访问
  • |
  • |

文件和目录访问¶

本章中描述的模块处理磁盘文件和目录。 例如,有一些模块用于读取文件的属性,以可移植的方式操作路径以及创建临时文件。 本章的完整模块列表如下:

  • pathlib --- 面向对象的文件系统路径
    • 基础使用
    • 纯路径
      • 通用性质
      • 运算符
      • 访问个别部分
      • 方法和特征属性
    • 具体路径
      • Querying file type and status
      • Reading and writing files
      • Reading directories
      • Creating files and directories
      • Renaming and deleting
      • 其他方法
    • Correspondence to tools in the os module
  • os.path --- 常用的路径操作
  • fileinput --- 迭代来自多个输入流的行
  • stat --- Interpreting stat() results
  • filecmp --- 文件和目录比较
    • dircmp 类
  • tempfile --- 生成临时文件和目录
    • 例子
    • 已弃用的函数和变量
  • glob --- Unix style pathname pattern expansion
  • fnmatch --- Unix 文件名模式匹配
  • linecache --- 随机访问文本行
  • shutil --- High-level file operations
    • 目录和文件操作
      • 依赖于具体平台的高效拷贝操作
      • copytree 示例
      • rmtree 示例
    • 归档操作
      • 归档程序示例
      • 使用 base_dir 的归档程序示例
    • 查询输出终端的尺寸

参见

模块 os

操作系统接口,包括处理比 Python 文件对象 更低级别文件的功能。

模块 io

Python的内置 I/O 库,包括抽象类和一些具体的类,如文件 I/O 。

内置函数 open()

使用 Python 打开文件进行读写的标准方法。

上一主题

operator --- 标准运算符对应函数

下一主题

pathlib --- 面向对象的文件系统路径

当前页

  • 报告 Bug
  • 显示源码
«

导航

  • 索引
  • 模块 |
  • 下一页 |
  • 上一页 |
  • Python logo
  • Python »
  • 3.12.4 Documentation »
  • Python 标准库 »
  • 文件和目录访问
  • |
  • |
© 版权所有 2001-2024, Python Software Foundation.
This page is licensed under the Python Software Foundation License Version 2.
Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
See History and License for more information.

The Python Software Foundation is a non-profit corporation. Please donate.

最后更新于 Jun 18, 2024 (21:19 UTC). Found a bug?
由 Sphinx 7.3.7创建。