首页 > 技术文章 > python修改图片名

Lazycat1206 2020-03-01 14:44 原文

1 import glob
2 import os
3 
4 inputPath = r'E:/data/pic/cat'
5 fileList = glob.glob(inputPath + '/*')
6 cnt = 0
7 for path in fileList:
8     os.rename(path, inputPath+'/'+str(cnt).zfill(6)+path[path.rfind('.'):])
9     cnt +=1

 

推荐阅读