python根据路径对单个文件进行重命名
学习来源:https://blog.csdn.net/jiahao1186/article/details/89316031
#导入模块
import os
#输入路径
srcFile = '/Users/ganyuning/Desktop/pic/未命名.txt'
#输出路径
dstFile = '/Users/ganyuning/Desktop/pic/123.txt'
#命名方法
try:
os.rename(srcFile,dstFile)
except Exception as e:
print(e)
print('rename file fail\r\n')
else:
print('rename file success\r\n')
赞 (0)