Skip to main content

汉语拼音转换工具.

Project description

Join the chat at https://gitter.im/mozillazg/python-pinyin

Build Coverage PyPI version PyPI downloads

将汉语转为拼音。可以用于汉字注音、排序、检索。

基于 hotoo/pinyin 开发。

特性

  • 根据词组智能匹配最正确的拼音。

  • 支持多音字。

  • 简单的繁体支持。

  • 支持多种不同拼音风格。

安装

$ pip install pypinyin

文档

详细文档请访问:http://pypinyin.mozillazg.com

使用示例

>>> from pypinyin import pinyin, lazy_pinyin
>>> import pypinyin
>>> pinyin(u'中心')
[[u'zh\u014dng'], [u'x\u012bn']]
>>> pinyin(u'中心', heteronym=True)  # 启用多音字模式
[[u'zh\u014dng', u'zh\xf2ng'], [u'x\u012bn']]
>>> pinyin(u'中心', style=pypinyin.FIRST_LETTER)  # 设置拼音风格
[['z'], ['x']]
>>> pinyin('中心', style=pypinyin.TONE2, heteronym=True)
[['zho1ng', 'zho4ng'], ['xi1n']]
>>> lazy_pinyin(u'中心')  # 不考虑多音字的情况
['zhong', 'xin']

命令行工具:

$ pypinyin 音乐
yīn yuè
$ pypinyin -h

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pypinyin-0.12.1.tar.gz (732.3 kB view details)

Uploaded Source

Built Distribution

pypinyin-0.12.1-py2.py3-none-any.whl (740.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pypinyin-0.12.1.tar.gz.

File metadata

  • Download URL: pypinyin-0.12.1.tar.gz
  • Upload date:
  • Size: 732.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pypinyin-0.12.1.tar.gz
Algorithm Hash digest
SHA256 eb0188d385b337a42d96ebbf1e0b6cf8a6448f1ed1afad4cef6e20d87a9a29d9
MD5 dbf32a970075f35f7a3b0cd2114523df
BLAKE2b-256 ad3387174c28e7e77960d3bdc73df3ce06ac0197cf19e6053c056669b8c85e05

See more details on using hashes here.

File details

Details for the file pypinyin-0.12.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pypinyin-0.12.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 bdee1d42fc3a174f11283ee5747b4b34fd292af0704d6698df94eed3664e20e5
MD5 51aac69896711e20b1ba1ff530c1fc08
BLAKE2b-256 c3f210e96a87eb837c963d1b1adb6e8f5026836027c4c8156f5e766ef9829bb0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page