import os
def delete_txt_files(folder_path):
for root, dirs, files in os.walk(folder_path):
for file in files:
if file.endswith(".xml"):
file_path = os.path.join(root, file)
os.remove(file_path)
# 定义文件夹路径
folder_path = r"C:\Users\admin\Desktop\TP\TP\helmet\images"
# 执行删除
delete_txt_files(folder_path)
删除文件夹内某个类型的文件
最新推荐文章于 2024-06-19 09:16:14 发布