问题描述 before: after: 代码: # -*- coding: utf-8 -*- import os path = 'E:/CSRNet-pytorch-master/data/original/shanghaitech/part_B_final/train_data/images' num = 1 for file in os.listdir(path): os.rename(os.path.join(path,file),os.path.join(path,'IMG_'+str(num)+".jpg")) num+=1