使用python将文件夹内的所有文件的中文名中的第1个中文字转换成英文大写,加1个空格后再连接原有的中文名...

可以使用Python的os模块和string模块,来实现这个功能:import os import stringdef translate_name(name): # 将第一个汉字转换成英文大写,加1个空格后再连接原有的中文名 first_word = name[0] first_word = first_word.upper() name = first_word + ' ' + name[1:] return namepath = '.' # 要处理的文件夹路径 files = os.listdir(path) for file in files:

猜你喜欢

转载自blog.csdn.net/weixin_42584758/article/details/129590823
今日推荐