1. 程式人生 > 其它 >python 圖片名稱修改

python 圖片名稱修改

技術標籤:python 雜七雜八python

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)