【高效办公】OS模块对文件夹所有文件重命名

import os


def Rename(path):
    file_name = os.listdir(path)
    # print(file_name)
    p_0=len(file_name)
    p=0
    for name in file_name:
        old_path = path+'\\'+name
        new_path = path+'\\'+'2月'+name
        os.renames(old_path,new_path)

path = 'D:\工作\业务策略板块\项目\线上学时分析'
Rename(path)

你可能感兴趣的:(python)