python 图片名称修改
def change_name():
import os
from PIL import Image
path = u'C:/Users/Administrator/Desktop/imgs/abc/abcd/' # 原始图片位置
newpath = u'C:/Users/Administrator/Desktop/new_imgs/' # 保存图片位置
filelists = os.listdir(path)
for line in filelists:
check = str(line)[-7:-4]
if int(check) < 100:
check = str(line)[-6:-4]
print check
img = Image.open(path + line)
out = 'normal_{}_10.png'.format(check)
img.save(newpath + out)