Pinyin

A simple python script to translate chinese to pinyin based on Mandarin.dat


Project maintained by lxyu Hosted on GitHub Pages — Theme by mattgraham

Pinyin

Translate chinese chars to pinyin based on Mandarin.dat

Install

$ pip install pinyin

Usage

>>> import pinyin
>>> print pinyin.get('你 好')
nǐ hǎo

>>> print pinyin.get('你好', format="strip", delimiter=" ")
ni hao

>>> print pinyin.get('你好', format="numerical")
ni3hao3

>>> print pinyin.get_initial('你好')
n h

format must be one of: numerical/diacritical/strip