import os,syspath = "D:/ps-pdf2/"# 獲取該目錄下全部文件,存入列表中fileList = os.listdir(path)n=11while n<99 : oldname = "PyQt5快速開發與實戰電子書-" + str(n + 1) + ".jpg" newname = "PyQt5快速開發與實戰電子書-" + "0" + str(n + 1) + ".jpg" oldname2 = path + oldname newname2 = path + newname os.rename(oldname2, newname2) print(oldname2, newname2) n+=1