依据文档批次命名图片
import os
def characters_sort(path):
with open(path,mode="r",encoding='utf-8')as f:
li=[]
for i in f:
li.append(i.strip())
l=''.join(li)
s=[]
for i in l:
if i not in[',','。','、']:
s.append(i)
s=''.join(s)
return s
ret=characters_sort('苕溪诗')
print(ret)
li=os.listdir(r'C:\Users\lenovo\Desktop\123')
print(li)
os.chdir(r'C:\Users\lenovo\Desktop\123')
k=0
for i in li:
os.rename(i, f'{k}{ret[k]}.jpg')
k+=1