参考博客:https://www.cnblogs.com/robin2ML/p/6739955.html
以下为简单尝试写的代码
import os filepath = 'D:\\abc' # 绝对路径 if __name__=='__main__': for filename in os.listdir(filepath): # print(filename) # """ list = filename.split('_') list[0] = 'abcd' newname = '_'.join(list) os.rename(os.path.join(filepath, filename), os.path.join(filepath, newname))