import os import shutil os.remove(path) #刪除文件 os.removedirs(path) #刪除空文件夾 shutil.rmtree(path) #遞歸刪除文件夾