标签:for pen form ges logs alt join mat img
效果如下:0001号用户的第 i 张图片
代码:
import os class ImageRename(): def __init__(self): self.path = ‘C:/Users/lbpeng/Desktop/test/chictopia2/images1/fashioninmysoul/full‘ def rename(self): filelist = os.listdir(self.path) totalnum = len(filelist) i = 1 for item in filelist: if item.endswith(‘.jpg‘): src = os.path.join(os.path.abspath(self.path), item) dst = os.path.join(os.path.abspath( self.path), ‘0001‘ + format(str(i), ‘0>3s‘) + ‘.jpg‘) os.rename(src, dst) i = i + 1 if __name__ == ‘__main__‘: newname = ImageRename() newname.rename()
标签:for pen form ges logs alt join mat img
原文地址:http://www.cnblogs.com/CongYuUestcer/p/7598574.html