【Python编程】批量删除文件夹中不需要的图片

import os
import cv2
import shutil
    
path6=r'E:\系统默认\桌面\pytorch-CycleGAN-and-pix2pix123\results\RGB2TOF_pix2pix'
folders=os.listdir(path6)
    
for image in folders: 
    print(image)

    if image.endswith('(2).png'):
         os.remove(os.path.join(path6,image))
        

猜你喜欢

转载自blog.csdn.net/lingchen1906/article/details/133088883