普贤教程 › 包参考
toml 包
TOML 配置解析(子集)
| 项 | 值 |
|---|---|
| 包名 | toml |
| 版本 | 0.2.0 |
| 可用版本 | 0.1.0 / 0.2.0 |
| 入口 | toml.px |
| 分类 | 数据格式与编解码 |
| 文件数 / 行数 | 1 / 328 |
安装与引入
bash
pxpkg init # 首次 pxpkg add toml@0.2.0 pxpkg install
px
import toml所属分类教程:数据格式与编解码
公开接口
| 函数 | 参数 |
|---|---|
toml_parse | s |
其余 14 个 def(内部与辅助,可直接调用但不属稳定接口)
| 函数 | 参数 |
|---|---|
toml_err_msg | r |
toml_strip_comment | line |
toml_find_eq | line |
toml_parse_value | txt, start |
toml_scalar | v |
toml_is_int | s |
toml_is_float | s |
toml_unescape | s |
toml_set_path | root, path, value |
toml_bracket_balance | line |
toml_has_key | root, key |
toml_get_keys | root |
toml_to_string | root |
toml_get_default | root, key, default |
包内说明(源码头注释)
text
============================================================ 普贤生态库:registry/toml —— TOML 配置解析(子集) ------------------------------------------------------------ 纯函数库(无 IO、无状态),编译(px build)与解释(px run)双模式一致。 toml_parse(s) → Ok(dict) | Err 支持: key = value 基础键值 "str" / 'str' / [1,2,3] / 1.5 / true / false / 整数 # 注释(行末) [section] / [section.sub] 表嵌套(点路径) 多行数组(方括号内换行) 表格顺序:键按出现顺序;子表挂 parent 下。 ============================================================