我想要此功能刪除文件。它正確地做到了這一點,但它也刪除我不想要的文件夾。刪除文件開始於
我也執行過程中出現錯誤:
Access is denied: 'C:/temp3\\IDB_KKK
在文件夾TEMP3我有:
IDB_OPP.txt
IDB_KKK - folder
代碼:
def delete_Files_StartWith(Path,Start_With_Key):
my_dir = Path
for fname in os.listdir(my_dir):
if fname.startswith(Start_With_Key):
os.remove(os.path.join(my_dir, fname))
delete_Files_StartWith("C:/temp3","IDB_")
縮短措辭,固定句子結構,改進代碼格式。 – Prune