处理中文字符串遇到了繁体和简体中文的转换,python版:
1、下载zh_wiki.py及langconv
zh_wiki.py:
langconv.py:
2、# -*- 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代码所在目录即可。