python 的 Tqdm 进度条模块的使用
2018-12-12 19:16
387 查看
python 的 Tqdm 进度条模块的使用
安装
使用pip进行安装:
pip install tqdm
简单使用方法
tqdm可以包裹任何迭代器,对迭代器添加进度条显示。比如,我们写一个从1 到 10000的循环,然后使用tqdm生成
from tqdm import tqdm import sleep for i in tqdm(range(10000)): sleep(0.5)
进度条,效果如下:
4%|▍ | 38/1000 [00:03<01:36, 9.93it/s]
也可以在迭代器外面单独处理进度条
pbar = tqdm(["a", "b", "c", "d"]) for char in pbar: pbar.set_description("processing %s" %char)
进度条效果如下:
processing d: 100%|██████████| 4/4 [00:27<00:00, 6.83s/it]
你也可以手动控制进度更新
with tqdm(total=100) as pbar: for i in range(10): pbar.update(10)
进度条效果如下:
100%|██████████| 100/100 [00:00<?, ?it/s]
tqdm也可以直接在命令行中使用
time find. -name '*.py' -exec cat \{} \; | wc -l
相关文章推荐
- python tqdm进度条模块
- python的Tqdm模块的使用
- [有趣的Python 8]使用C模块来提高性能 [转]
- Base64 编码原理简介和python的base64模块的使用
- Python的内存泄漏及gc模块的使用
- Python:使用getopt模块处理命令行参数[zt]
- 使用 Boost.Python 嵌入 Python 模块到 C++
- python 学习记录(5)-变量、模块名的命名规则及random模块使用
- Python:使用threading模块实现多线程编程五[死锁的形成]
- python模块之threading: 在python中使用多线程
- PYTHON正则表达式 re模块使用说明
- 使用C++来写Python扩展模块
- 使用f2py将C语言的函数转换为python模块
- python pygame模块的使用
- Python:使用threading模块实现多线程编程一[综述]
- python使用time模块格式化时间
- Python中cmd模块的使用说明
- python optparse 模块使用
- 使用Python(comtypes)操作ArcGis(ArcObject)的第一步:安装模块到gen文件夹中
- 今天犯了一个很蠢的错误,有关python的模块包的使用的