px普贤教程PuXian
普贤教程 › 包参考

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_thousandsn
th_thousands_strs
th_ordinaln
其余 5 个 def(内部与辅助,可直接调用但不属稳定接口)
函数参数
th_digit_thousandss
th_compactn
th_bytesn
th_thousands_floatf
th_parses

包内说明(源码头注释)

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() 转换(任意长度安全)。
============================================================