Registry / data / cn2an
library0.5.24pypypiunverified

cn2an is a Python toolkit for quickly converting between Chinese numerals and Arabic numerals. It supports conversion of standard Chinese numbers, large-form Chinese numbers, mixed Chinese and Arabic numbers, and provides features for sentence-level conversion, including dates, fractions, percentages, and temperatures. The library is actively maintained, with the latest version being 0.5.23, and targets Python 3.6+ for local installation.

pip install cn2an -U
INSTALL
IMPORT
SIG · CN2AN
C
cn2an
datapythonv0.5.24
Install
1.7s avg
Import
1476ms
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.5.24 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 1.581s · 20.5MB
glibc
py 3.10–3.920 runs
installs and imports cleanly · install 1.7s · import 1.371s · 21MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cn2an
✓ import cn2an

Demonstrates basic conversion from Chinese to Arabic and Arabic to Chinese numerals, along with sentence-level transformation. Various modes (`strict`, `normal`, `smart` for cn2an; `low`, `up`, `rmb` for an2cn) are available to handle different input formats.

import cn2an # Chinese to Arabic conversion (strict mode is default) arabic_num = cn2an.cn2an("一百二十三") print(f"'一百二十三' -> {arabic_num}") # Arabic to Chinese conversion (low mode is default) chinese_num = cn2an.an2cn("12345") print(f"'12345' -> {chinese_num}") # Sentence transformation (experimental) sentence = cn2an.transform("小王捡了一百块钱") print(f"'小王捡了一百块钱' -> {sentence}")
Debug
Known issues
breakingOlder versions of cn2an (e.g., v0.1.0) claimed Python 2.7 support. Current versions (0.3.3 onwards) explicitly require Python 3.6 or higher. Attempting to install or use on Python 2.x will result in an error.
fix
Ensure your environment uses Python 3.6 or newer. Upgrade your Python interpreter if necessary.
affects: <0.3.3 supported Python 2.x, >=0.3.3 requires Python 3.6+
gotchaThe `cn2an.transform()` method is considered experimental and might produce unexpected or inaccurate conversions for complex sentences.
fix
For critical applications, carefully test `transform()` with your specific sentence patterns. Consider using `cn2an.cn2an()` or `cn2an.an2cn()` on extracted number phrases for more predictable results.
affects: All versions
gotchaBoth `cn2an.cn2an()` and `cn2an.an2cn()` functions accept a `mode` parameter (e.g., 'strict', 'normal', 'smart' for Chinese to Arabic; 'low', 'up', 'rmb' for Arabic to Chinese). Not understanding or specifying the correct mode for your input can lead to incorrect or unexpected conversion results.
fix
Consult the documentation for available modes and their specific behaviors. Explicitly pass the desired `mode` argument to the conversion functions (e.g., `cn2an.cn2an('一二三', 'normal')`) to ensure correct parsing.
affects: All versions
Upgrade
Version history
0.5.24latest on PyPI · released Apr 22, 2026
Audit
Dependencies
PythonrequiredRequired Python version for local installation.
Agent activity
40 hits · last 30 days
node
34
OpenAI (training)
1
Resources
cn2an — pip install cn2an · libregistry