import os
import sys
def removeFile(path,type_extension):
filelist = os.listdir(path)
for file in filelist:
filepath = os.path.join(path,file)
if os.path.isdir(filepath):
removeFile(filepath,type_extension)
else:
if os.path.splitext(filepath)[1]==type_extension:
os.remove(filepath)
removeFile("D:\\英文版",r".txt") #这假设筛选的所有txt文件
网友评论