话不多说直接上代码
#先导入所需的包
import os
#指定路径
path = '/Users/akun/Desktop/项目/PaChongcode/Image/'
for root, dirs, files in os.walk(path):
for name in files:
if name.endswith(".png"): # 填写规则
os.remove(os.path.join(root, name))
print("Delete File: " + os.path.join(root, name))
?