普贤教程 › 包参考
progress 包
进度条渲染
| 项 | 值 |
|---|---|
| 包名 | progress |
| 版本 | 0.2.0 |
| 可用版本 | 0.1.0 / 0.2.0 |
| 入口 | progress.px |
| 分类 | 文本与中文处理 |
| 文件数 / 行数 | 1 / 113 |
安装与引入
bash
pxpkg init # 首次 pxpkg add progress@0.2.0 pxpkg install
px
import progress所属分类教程:文本与中文处理
公开接口
| 函数 | 参数 |
|---|---|
pg_bar | done, total, width=40, opts={} |
其余 7 个 def(内部与辅助,可直接调用但不属稳定接口)
| 函数 | 参数 |
|---|---|
pg_spinner | frame |
pg_percent | done, total |
pg_eta | done, total, elapsed_sec |
pg_format_time | sec |
pg_bar_custom | done, total, width, fill_char, empty_char |
pg_bar_num | done, total, width=30 |
pg_speed | bytes_done, elapsed_sec |
包内说明(源码头注释)
text
============================================================ 普贤生态库:registry/progress —— 进度条渲染 ------------------------------------------------------------ 纯函数库(无 IO、无状态;不直接改终端,返回可打印字符串),双模式一致。 pg_bar(done, total, width=40, opts={}) → Ok(str) | Err opts: {fill(默认"#"), empty(默认"-"), show_pct(默认 true), show_count(默认 false)} 输出形如 "[#####-----] 50%";done 夹取 0..total;total<=0 Err。 ============================================================