中文和阿拉伯数字互转
Project description
Copied from my git repo https://github.com/zcold/pycnnum.
Usage
This package exposes two methods for conversion between Chinese string and int/float number.
Chinese string to number cn2num
>>> from pycnnum import cn2num
>>> cn2num("一百八")
180
>>> cn2num("十五")
15
>>> cn2num("负十五")
-15
>>> cn2num("一百八十")
180
>>> cn2num("一百八点五六七")
180.567
>>> cn2num("两千万一百八十")
20000180
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)
'一千六'
Development
- Create a virtual env
venv - Activate the virtual env
- Run
python -m pip install .[dev]
VSCodetask for creating API document is in.vscode/tasks.json.VSCodedebugger configuration for fixing issues withpytest-covis 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 details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
pycnnum-2.0.0-py3-none-any.whl
(10.1 kB
view details)
File details
Details for the file pycnnum-2.0.0.tar.gz.
File metadata
- Download URL: pycnnum-2.0.0.tar.gz
- Upload date:
- Size: 18.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.27.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcdb82ff55e66969b1dcc4b6056def090137359980408e57656c36e4df8ee954
|
|
| MD5 |
3f0a3a1a4616c4017e12eff047c1d047
|
|
| BLAKE2b-256 |
04e8cd46369d869541117b7a20c7f88d9d0edb138cdbf71581f0511fc85a7cfe
|
File details
Details for the file pycnnum-2.0.0-py3-none-any.whl.
File metadata
- Download URL: pycnnum-2.0.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.27.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1c1da6c8ebadee27a6011d0dbc8b116ac39eb533f7f4bca64cde3713fbd8f70
|
|
| MD5 |
ee5b62a1da08268ee93ca6b9fe788d45
|
|
| BLAKE2b-256 |
5318076f1144d1ceb6be4c50b7ed0139960f1690df05cfff6aa03fd796cc0e06
|