import os, sys
from PIL import Image
"""
将filePath文件下的图片保存在newFilePath文件夹下的相应子文件夹中
pic 是字典,存放每个图片要移到的子文件夹名
"""
def moveImg(filePath, newFilePath, pic):
filePath = unicode(filePath, "utf8")
newFilePath = unicode(newFilePath, "utf8")
for root, dirs, files in os.walk(filePath):
for f in files:
fl = filePath + '/' + f
img = Image.open(fl)
img.save(newFilePath + '/' + pic[f[:-4]] + '/' + f)
python---将一个文件夹下的图片移到另一个文件夹
最新推荐文章于 2024-07-25 03:58:17 发布