批量删除文件夹中指定类型的文件os.remove
import os
def delFiles(filePath):
for root, dirs, files in os.walk(filePath):
print(root, dirs, files)
for name in files:
if name.endswith(".JPG"):
os.remove(os.path.join(root, name))
if __name__ == "__main__":
filepath = r'./filepath'
delFiles(filepath)