Requirements: The Chinese character strings for traditional and simplified Chinese conversion;
Idea: Introduction of simple traditional processing library, interested students can study the internal implementation, are written by 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 it in the directory where Python code is located
2. code example
1234567891011 |
# -*- 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‘
)
|
www.qytang.com/
http://www.qytang.com/cn/list/29/
http://www.qytang.com/cn/list/28/428.htm
http://www.qytang.com/cn/list/28/426.htm
http://www.qytang.com/cn/list/28/425.htm
http://www.qytang.com/cn/list/28/424.htm
http://www.qytang.com/cn/list/28/423.htm
http://www.qytang.com/cn/list/28/422.htm
http://www.qytang.com/cn/list/28/421.htm
http://www.qytang.com/cn/list/28/420.htm
http://www.qytang.com/cn/list/28/417.htm
http://www.qytang.com/cn/list/28/416.htm
http://www.qytang.com/cn/list/28/407.htm
http://www.qytang.com/cn/list/28/403.htm
Python implementation Chinese characters traditional and simplified English conversion-Yihe Hall