普贤教程 › 包参考
thousep 包
数字千分位 / 序数格式
| 项 | 值 |
|---|---|
| 包名 | thousep |
| 版本 | 0.2.0 |
| 可用版本 | 0.1.0 / 0.2.0 |
| 入口 | thousep.px |
| 分类 | 数学与统计 |
| 文件数 / 行数 | 1 / 158 |
安装与引入
bash
pxpkg init # 首次 pxpkg add thousep@0.2.0 pxpkg install
px
import thousep所属分类教程:数学与统计
公开接口
| 函数 | 参数 |
|---|---|
th_thousands | n |
th_thousands_str | s |
th_ordinal | n |
其余 5 个 def(内部与辅助,可直接调用但不属稳定接口)
| 函数 | 参数 |
|---|---|
th_digit_thousands | s |
th_compact | n |
th_bytes | n |
th_thousands_float | f |
th_parse | s |
包内说明(源码头注释)
text
============================================================ 普贤生态库:registry/thousep —— 数字千分位 / 序数格式 ------------------------------------------------------------ 纯函数库(无 IO、无状态),编译(px build)与解释(px run)双模式一致。 th_thousands(n) → str int → "1,234,567"(负号保留) th_thousands_str(s) → Ok(str) | Err 数字字符串(可带小数)千分位 th_ordinal(n) → str "1st" / "2nd" / "3rd" / "11th" / "21st" 实现:纯字符串逆序三分处理,整数部分不经过 int() 转换(任意长度安全)。 ============================================================