1.python库pypinyin
可以使用 pip 进行安装:
$ pip install pypinyin
easy_install 安装:
$ easy_install pypinyin
源码安装:
$ python setup.py install
pypinyin0.28.0文档:
http://pypinyin.mozillazg.com/zh_CN/master/index.html
2.python库xpinyin
安装:pip install xpinyin
- 这是个中文转拼音的pakage
>>> from xpinyin import Pinyin >>> p = Pinyin() >>> # default splitter is `-` >>> p.get_pinyin(u"上海") 'shang-hai' >>> # show tone marks >>> p.get_pinyin(u"上海", show_tone_marks=True) 'shàng-hǎi' >>> # remove splitter >>> p.get_pinyin(u"上海", '') 'shanghai' >>> # set splitter as whitespace >>> p.get_pinyin(u"上海", ' ') 'shang hai' >>> p.get_initial(u"上") 'S' >>> p.get_initials(u"上海") 'S-H' >>> p.get_initials(u"上海", u'') 'SH' >>> p.get_initials(u"上海", u' ') 'S H'
3.python库pinyin