Skip to main content


Project description

Copied from my git repo


This package exposes two methods for conversion between Chinese string and int/float number.

Chinese string to number cn2num

>>> from pycnnum import cn2num
>>> cn2num("一百八")
>>> cn2num("十五")
>>> cn2num("负十五")
>>> cn2num("一百八十")
>>> cn2num("一百八点五六七")
>>> cn2num("两千万一百八十")

Number to Chinese string num2cn

from pycnnum import num2cn
>>> num2cn('023232.005184132423423423300', numbering_type="high", alt_two=True, capitalize=False, traditional=True)
>>> num2cn('023232.005184132423423423300', numbering_type="high", alt_two=False, capitalize=False, traditional=True)
>>> num2cn(111180000)
>>> num2cn(1821010)
>>> num2cn(182.1)
>>> num2cn('3.4')
>>> num2cn(16)
>>> num2cn(10600)
>>> num2cn(110)
>>> num2cn(1600)


  1. Create a virtual env venv
  2. Activate the virtual env
  3. Run python -m pip install .[dev]
  • VSCode task for creating API document is in .vscode/tasks.json.
  • VSCode debugger configuration for fixing issues with pytest-cov is in .vscode/launch.json.

Project details

Download files

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

Source Distribution

pycnnum-2.0.0.tar.gz (18.2 kB view hashes)

Uploaded source

Built Distribution

pycnnum-2.0.0-py3-none-any.whl (10.1 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page