python修改图片名
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
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