美文网首页
Python 文件与目录操作方法总结

Python 文件与目录操作方法总结

作者: BioIT爱好者 | 来源:发表于2019-02-18 08:56 被阅读0次

Python 有很多内置的模块和函数可用于文件的操作处理,这些函数都分布在几个模块上:如 os,os.path,shutil 和pathlib 等等。本文收集了许多您需要知道的函数,以便在 Python 中对文件执行最常见的操作。、

通过本教程,你可以:

  • 检索文件属性
    Retrieve file properties
  • 创建目录
    Create directories
  • 基于文件名的模式匹配
    Match patterns in filenames
  • 遍历目录树
    Traverse directory trees
  • 创建临时文件和目录
    Make temporary files and directories
  • 删除文件和目录
    Delete files and directories
  • 拷贝、转移、重命名文件和目录
    Copy, move, or rename files and directories
  • 创建和提取 ZI P和 TAR 打包
    Create and extract ZIP and TAR archives
  • 使用 fileinput 模块打开多个文件
    Open multiple files using the fileinput module

文章链接:https://www.yuque.com/shenweiyan/bioit/python-file-process

相关文章

网友评论

      本文标题:Python 文件与目录操作方法总结

      本文链接:https://www.haomeiwen.com/subject/hapoeqtx.html