0
点赞
收藏
分享

微信扫一扫

Python文件名繁体转简体

谷中百合517 2022-04-23 阅读 260
python

文件名繁体转简体

import os
import opencc

route = r"这里把文件目录粘贴进去"  # 文件所在目录
file_list = os.listdir(route)  # 获取文件列表
for file in file_list:
    converter = opencc.OpenCC('t2s')  # 设置转换格式为:繁体转简体
    s_name = converter.convert(file)
    os.rename(route + "\\" + file, route + "\\" + s_name)  # 重命名,设置文件位置

举报

相关推荐

0 条评论