Python实现从文件夹中筛选指定的图片取出

Python实现从文件夹中筛选指定的图片取出


import os
import shutil

imgs = ['a.jpg','b.jpg','c.jpg','d.jpg']
if __name__ == '__main__':
    for img in imgs:
        path = 'D:\\test\\images\\' + img
        if os.path.exists(path):
            shutil.move(path, 'D:\\test\\screen')
        else:
            print(img)
    pass

文档信息

Search

    Table of Contents