我正在運行一個腳本,該腳本遍歷目錄結構並在目錄中的每個文件夾中生成新文件。我想在創建後立即刪除一些文件。這是我的想法,但它是錯誤的我想象:刪除Python中的某些文件類型
directory = os.path.dirname(obj)
m = MeshExporterApplication(directory)
os.remove(os.path.join(directory,"*.mesh.xml"))
如何將通配符放入路徑?我想不喜歡/home/me/*.txt,但這正是我正在嘗試的。
感謝, 加雷思
他還需要'os.path.join'。 – 2010-06-03 00:58:50
或glob中的絕對路徑。 – miku 2010-06-03 00:59:16