目錄操作:
os.mkdir("file") ? ? ? ? ? ? ? ? ? 創(chuàng)建目錄
復制文件:
shutil.copyfile("oldfile","newfile") ? ? ? oldfile和newfile都只能是文件
shutil.copy("oldfile","newfile") ? ? ? ? ? ?oldfile只能是文件夾,newfile可以是文件队贱,也可以是目標目錄
復制文件夾:
shutil.copytree("olddir","newdir") ? ? ? ?olddir和newdir都只能是目錄崖叫,且newdir必須不存在
重命名文件(目錄)
os.rename("oldname","newname") ? ? ? 文件或目錄都是使用這條命令
移動文件(目錄)
shutil.move("oldpos","newpos")
刪除文件
os.remove("file")
刪除目錄
os.rmdir("dir")只能刪除空目錄
shutil.rmtree("dir") ? ?空目錄、有內容的目錄都可以刪
轉換目錄
os.chdir("path") ? 換當前路徑