Skip to main content

cn2int: Chinese Numerals To Int/Float

  • Conversion bettwen Chinese numerals and integer/float.
  • Conversion bettwen Roman numerals and integer.

cn2int does the format checking during conversion, it can raise ValueError, OverflowError and KeyError. Before doing conversion, you should ensure the following patterns are met.

  • roman2int: "[IVXLCDM]+"
  • chinese2int: "[正负負]?[〇一二三四五六七八九十百千万亿零壹贰叁肆伍陆柒捌玖拾佰仟萬億两]+"
  • chinese2float: "[正负負]?[〇一二三四五六七八九十百千万亿零壹贰叁肆伍陆柒捌玖拾佰仟萬億两点點]+"

Usage

import cn2int as c2i

# chinese/roman/arab => integer
c2i.convert2int("两亿零六千五")

# chinese => integer
c2i.chinese2int("二十三亿零六百三十万零七十八")

# chinese => float
c2i.chinese2float("二千三百零六万三千点七八")

# integer => chinese
c2i.int2chinese(2306300078)

# float => chinese
c2i.float2chinese(23063000.78)

# rooman => integer
c2i.roman2int("XVI")

# integer => rooman
c2i.int2roman(16)

# performance
c2i.performance()

Release files for cn2int 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cn2int 0.2.3
File Size Uploaded
cn2int-0.2.3.tar.gz 11.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cn2int 0.2.3
File Interpreter ABI Platform
cn2int-0.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 18.9 kB

Release files / cn2int-0.2.3.tar.gz

Download URL cn2int-0.2.3.tar.gz
Size 11.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ea2233a0ab5aecfa55f5884efc0d788910e88a1f6757de484cdd06402df9fe63
BLAKE2b-256 checksum
How to use checksums
b1d59fb02df58517edd96951d2f49193afafeab00997af896c0a303a08f5c961
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / cn2int-0.2.3-py3-none-any.whl

Download URL cn2int-0.2.3-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3ab982680a1bea452e3ecba219f7c1217f134c12e23b58f049f28103b7a91466
BLAKE2b-256 checksum
How to use checksums
12690aff5762f8ca9d6c68bd3129cb5df650ef581d643c3591b0f9755c55ef07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release history Release notifications | RSS feed

This release

0.2.3 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page