Skip to main content

Conversion bettwen Chinese number and integer/float

Project description

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

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

cn2int-0.2.3.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

cn2int-0.2.3-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file cn2int-0.2.3.tar.gz.

File metadata

  • Download URL: cn2int-0.2.3.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for cn2int-0.2.3.tar.gz
Algorithm Hash digest
SHA256 ea2233a0ab5aecfa55f5884efc0d788910e88a1f6757de484cdd06402df9fe63
MD5 8d8446e129554414086031c54865b011
BLAKE2b-256 b1d59fb02df58517edd96951d2f49193afafeab00997af896c0a303a08f5c961

See more details on using hashes here.

File details

Details for the file cn2int-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: cn2int-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for cn2int-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3ab982680a1bea452e3ecba219f7c1217f134c12e23b58f049f28103b7a91466
MD5 d46febdb809dceb7293762e7c82c27a7
BLAKE2b-256 12690aff5762f8ca9d6c68bd3129cb5df650ef581d643c3591b0f9755c55ef07

See more details on using hashes here.

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