import os import sys def rename(): path=input("请输入路径:") count=1 filelist=os.listdir(path) for files in filelist: ori_dir=os.path.join(path,files) if os.path.isdir(ori_dir):#跳过目录 continue now_dir = os.path.join(path, 'SteroSR_x4_epoch'+str(count)+'.pth') os.rename(ori_dir,now_dir) count+=1 print("一共修改了"+str(count-1)+"个文件") rename()