Skip to main content

汉语拼音转换工具

Project description

Build Coverage Pypi version Pypi downloads

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

Installation

To install pypinyin, simply:

$ pip install pypinyin

Basic Usage

>>> 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.STYLE_INITIALS)  # 设置拼音风格
[['zh'], ['x']]
>>> lazy_pinyin(u'中心')
['zhong', 'xin']

Changelog

0.3.1 (2013-12-24)

  • 增加 lazy_pinyin

    >>> lazy_pinyin(u'中心')
    ['zhong', 'xin']

0.3.0 (2013-09-26)

  • 修复首字母风格无法正确处理只有韵母的汉字

  • 新增三个拼音风格:
    • pypinyin.STYLE_FINALS : 韵母风格1,只返回各个拼音的韵母部分,不带声调。如: ong uo

    • pypinyin.STYLE_FINALS_TONE : 韵母风格2,带声调,声调在韵母第一个字母上。如: ōng uó

    • pypinyin.STYLE_FINALS_TONE2 : 韵母风格2,带声调,声调在各个拼音之后,用数字 [0-4] 进行表示。如: o1ng uo2

0.2.0 (2013-09-22)

  • 完善对中英文混合字符串的支持:

    >> pypinyin.pinyin(u'你好abc')
    [[u'n\u01d0'], [u'h\u01ceo'], [u'abc']]

0.1.0 (2013-09-21)

  • Initial Release

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.3.1.zip (606.1 kB view details)

Uploaded Source

File details

Details for the file pypinyin-0.3.1.zip.

File metadata

  • Download URL: pypinyin-0.3.1.zip
  • Upload date:
  • Size: 606.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pypinyin-0.3.1.zip
Algorithm Hash digest
SHA256 f34bf88f457a602eac2db760af434b791e8cb92be03b1811edeb58b5e77f7372
MD5 702d29dc43b1c13b4ae22bce7175866c
BLAKE2b-256 efd19d8f3ddbd5f590c6762aa0df24814abbc5d5e3c0969040cf579dd15d2be9

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