原因:重命名需要把文件路径带上
源码:
for file in files: print(file) os.rename(file, file.replace(beforename, aftername))
修改后
for file in files: f=file.replace(beforename, aftername) os.rename(files+'\\'+file,files+'\\'+f)