import os
from PIL import Image
with open("test.txt")as fp: #读入ebayno,ebayno放在test.txt文件中
for line in fp:
ebayno = str(line.strip())
if os.path.exists("picture\\"+ebayno+".jpg"): #判断是否存在该图片
img = Image.open("picture\\"+ebayno+".jpg")
img.save("picture\\1\\"+ebayno+".jpg") #在picture下自定义一个子文件夹,此处文件名为1,名字可根据需要修改
else:
print(ebayno+ "不存在文件夹里")