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()



python  批量修改文件名_import




python  批量修改文件名_import_02



修改1
now_dir = os.path.join(path, 'img_'+str(count).zfill(3)+'_4_HR'+'.png')#不满3位,右对齐,前面补零