Requirement: convert Chinese strings to traditional and simplified Chinese. train of thought: Introduce the simplified and traditional Chinese processing library. if you are interested, you can study the internal implementation, all written in python. 1. download zh_wiki... requirement: convert Chinese strings to traditional and simplified Chinese;
Idea: Introduce the simplified and traditional Chinese processing library. if you are interested, you can study the internal implementation, which is written in python.
1. download zh_wiki.py and langconv
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
Download langconv. py and zh_wiki.py and put them in the directory where the python code is located.
2. code example
#-*-Coding: UTF-8-*-from langconv import * # convert traditional to simplified line = Converter ('zh-hans '). convert (line. decode ('utf-8') line = line. encode ('utf-8') # Convert simplified to traditional line = Converter ('zh-hant '). convert (line. decode ('utf-8') line = line. encode ('utf-8 ')