import os
def all(dir,ends):
list=os.listdir(dir)
for l in list:
if l.endswith(ends):
os.remove(dir+"\\"+l)
print("删除成功")
if __name__ == '__main__':
all("F:\\aaa",".png")
All png files to delete the specified folder
Guess you like
Origin blog.csdn.net/beyongboy/article/details/104878867
Recommended
Ranking