• 用open()创建文件

open('a.txt','wt')

  • 用exists()检查文件是否存在

os.path.exists()

  • 用isfile()检查是否为文件

os.path.isfile(name)

  • 用isdir()检查时候为文件夹

os.path.isdir(name)

  • 用copy()复制文件

import shutil
shutil.copy()

  • 用rename()重命名文件

import os
os.rename('a.txt','b.txt')

相关文章:

  • 2021-12-04
  • 2021-08-23
  • 2021-11-19
  • 2021-08-24
  • 2022-12-23
  • 2021-08-26
  • 2022-12-23
猜你喜欢
  • 2021-07-18
  • 2022-01-29
  • 2021-07-28
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
  • 2021-09-30
相关资源
相似解决方案