1. 判断
python3
可以 try: 编码为 big5hkscs
,不异常就说明是 big5hkscs
里的繁体字。
line = '我们今天去吃饭了'
l = '我們今天去吃飯了'
print(line.encode('utf-8'))
print(l.encode('utf-8'))
try:
print(l.encode('big5hkscs'))
print(line.encode('big5hkscs'))
except:
print(111)
2. 繁体简体转换
from model_traditional_conversion.langconv import *
#python3
# 转换繁体到简体
line = Converter('zh-hans').convert(line)
print(line)
# 转换简体到繁体
line = Converter('zh-hant').convert(line)
print(line)