普贤教程 › 包参考
num2words 包
英文数字转单词
| 项 | 值 |
|---|---|
| 包名 | num2words |
| 版本 | 0.2.0 |
| 可用版本 | 0.1.0 / 0.2.0 |
| 入口 | num2words.px |
| 分类 | 文本与中文处理 |
| 文件数 / 行数 | 1 / 160 |
安装与引入
bash
pxpkg init # 首次 pxpkg add num2words@0.2.0 pxpkg install
px
import num2words所属分类教程:文本与中文处理
公开接口
| 函数 | 参数 |
|---|---|
nw_convert | n |
其余 8 个 def(内部与辅助,可直接调用但不属稳定接口)
| 函数 | 参数 |
|---|---|
nw_ones | t |
nw_tens | t |
nw_two | n |
nw_three | n |
nw_abs | n |
nw_to_words_en | n |
nw_to_words_cn | n |
nw_currency | n, currency="CNY" |
包内说明(源码头注释)
text
============================================================ 普贤生态库:registry/num2words —— 英文数字转单词 ------------------------------------------------------------ 纯函数库(无 IO、无状态),编译(px build)与解释(px run)双模式一致。 nw_convert(n) → Ok(str) | Err 整数(±999,999,999,999)→ 英文单词 规则: - 0 → "zero";负 → "minus X" - 21-99 连字符(forty-two);百位后接 "and"(one hundred and five) - 千/百万/十亿分组(one thousand / one million / one billion) ============================================================