python实现中文繁体和中文简体之间的相互转换
用到了两个库,分别是zh_wiki.py和langconv.py
zh_wiki.py下载:
https://github.com/skydark/nstools/blob/master/zhtools/zh_wiki.py
langconv.py下载:
https://github.com/skydark/nstools/blob/master/zhtools/langconv.py
# -*- coding:utf-8 -*- from langconv import * # 转换繁体到简体 line = Converter('zh-hans').convert(line.decode('utf-8')) line = line.encode('utf-8') # 转换简体到繁体 line = Converter('zh-hant').convert(line.decode('utf-8')) line = line.encode('utf-8') 备注:只需从网上下载langconv.py和zh_wiki.py,放在python代码所在目录即可。
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/8170.html