python学习 复制图片并重命名

把图片从一个文件夹复制到另一个文件夹,并重命名

def cp_episode_normal(episode_i,mae):
    path='run_model/test'
    new_path='episode_normal_map'
    filelist = os.listdir(path)
    for item in filelist:
        new_name='{}{}{}{}{}'.format('mae of episode_', episode_i, ' is ', mae,' .png')
        shutil.copy(path+"/"+item , new_path+"/"+new_name)
cp_episode_normal(5,3.5)

你可能感兴趣的:(python)