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 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