
Security News
OWASP 2025 Top 10 Adds Software Supply Chain Failures, Ranked Top Community Concern
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.
.. image:: http://img.shields.io/pypi/v/pinyin.svg?style=flat :target: https://pypi.python.org/pypi/pinyin
.. image:: http://img.shields.io/travis/lxyu/pinyin/master.svg?style=flat :target: https://travis-ci.org/lxyu/pinyin
Translate chinese chars to pinyin based on Mandarin.dat
.. code:: bash
$ pip install pinyin
.. code:: python
>>> 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
.. note::
`format` must be one of: numerical/diacritical/strip
.. code:: python
>>> import pinyin.cedict
>>> pinyin.cedict.translate_word('你')
['you (informal, as opposed to courteous 您[nin2])']
>>> pinyin.cedict.translate_word('你好')
['Hello!', 'Hi!', 'How are you?']
>>> list(pinyin.cedict.all_phrase_translations('你好'))
[['你', ['you (informal, as opposed to courteous 您[nin2])']], ['你好', ['Hello!', 'Hi!', 'How are you?']], ['好', ['to be fond of', 'to have a tendency to', 'to be prone to']]]
Note that this is a prototype, and only functions from Python 3.
pinyin is free software, under an MIT-style license. See LICENSE for details.
The data file for translations is the CC-BY-SA 3.0.
The translations are from the CC-CE-DICT project (https://cc-cedict.org/wiki/), by Denisowski, Peterson, Brelsford, and others.
FAQs
Translate chinese chars to pinyin based on Mandarin.dat
We found that pinyin demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.