3.4 高级文件处理接口shutil
复制文件:
- shutil.copyfile("oldfile","newfile") # oldfile和newfile都只能是文件
- shutil.copy("oldfile","newfile") # oldfile只能是文件,newfile可以是文件,也可以是目标目录
复制文件夹:
- shutil.copytree("olddir","newdir") # olddir和newdir都只能是目录,且newdir必须不存在
移动文件(目录)
- shutil.move("oldpos","newpos")
删除目录:
- shutil.rmtree("dir") # 空目录,有内容的目录都可以删