【发布时间】:2021-06-05 06:04:38
【问题描述】:
警告使用此文件时可能会删除同一文件夹中的文件
嗨,这是一个用于删除文件的 python 3 脚本,我想知道如何防止它自行删除
代码:
import os
import sys
import glob
fileList = glob.glob('*.*')
print(fileList)
for filePath in fileList:
try:
os.remove(filePath)
except:
print("Error while deleting file : ", filePath)
【问题讨论】:
标签: python python-3.x delete-file