python3 练手实例8 批量命名图片

 1 import os
 2 path=input('请输入你的路径,以/结尾:')#我的路径 C:/Users/Administrator/Pictures/      -__-
 3 f=os.listdir(path)
 4 n=0
 5 name=input('请输入你要批量命名的名字:')#我批量命名的是 美女  -__-
 6 for i in f:
 7     old=path+f[n]
 8     new=path+name+str(n+1)+'.jpg'
 9     os.rename(old,new)
10     print(old,new)
11     n+=1

猜你喜欢

转载自www.cnblogs.com/limiao0819/p/9275399.html
今日推荐