Python converts traditional and simplified Chinese characters

Source: Internet
Author: User
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 ')

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.