这里需要用到两个文件,从github下载: https://github.com/csdz/nstools/tree/master/zhtools
下载源文件:zh_wiki.py 和 langconv.py
转换函数:
from langconv import *
def tradition2simple(line):
# 将繁体转换成简体
line = Converter('zh-hans').convert(line.decode('utf-8'))
line = line.encode('utf-8')
return line
def tradition2simple2(line):
# 将繁体转换成简体
line = Converter('zh-hans').convert(line)
line = line.encode('utf-8')
return line
a = tradition2simple2(u"無所謂")
print(a)
# 结果
无所谓