python3中TQDM库安装及使用详解
作者:十一 时间:2023-02-17 20:05:55
在一众有趣的Python库中,TQDW也算是独树一帜了,原因主要是因为自身所存在的功能效果,比如我们如果在写项目,往往会忘记我们要完成多少量,而这个库主要就是帮我们实时掌握进度,现在这样跟大家讲解,是不是都来了兴趣呢?因此,那就开启本章正题,给大家详解TQDM库的安装及使用。
先来说下安装,常用方式:
pipinstall tqdm
当for循环使用range函数时,只是把它替换为tqdm中的trange即可。
fromtqdm import trangefor i in trange(100):
sleep(0.01)
一般来说,对列表做循环。使用tqdm也很容易。
fromtqdm import tqdm
for e in tqdm([1,2,3,4,5,6,7,8,9]):
sleep(0.5) # Suppose we are doing something with theelements
效果演示:
实例扩展:
tqdm子模块
from tqdm import tqdm
for i in tqdm(range(100)):
pass
for j in tqdm([1,2,3,4,5]):
pass
trange 子模块
from tqdm import trange
for i in trange(100):
pass
来源:https://www.py.cn/jishu/jichu/20947.html
标签:python3,TQDM库
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python实现生活常识解答机器人
2021-06-22 14:34:36
![](https://img.aspxhome.com/file/2023/6/70726_0s.png)
mysql中数据库覆盖导入的几种方式总结
2024-01-19 22:26:33
![](https://img.aspxhome.com/file/2023/1/103131_0s.png)
python十进制转二进制的详解
2023-06-07 23:39:33
使用python和Django完成博客数据库的迁移方法
2022-05-16 03:58:25
![](https://img.aspxhome.com/file/2023/2/68992_0s.jpg)
python和shell获取文本内容的方法
2023-06-20 05:42:35
对python cv2批量灰度图片并保存的实例讲解
2022-06-11 18:21:36
python matplotlib 绘图 和 dpi对应关系详解
2023-12-11 18:13:43
![](https://img.aspxhome.com/file/2023/7/99477_0s.jpg)
numpy的sum函数的axis和keepdim参数详解
2021-08-02 02:48:46
python买卖股票的最佳时机(基于贪心/蛮力算法)
2022-12-26 14:44:24
![](https://img.aspxhome.com/file/2023/1/76891_0s.png)
Python检查和同步本地时间(北京时间)的实现方法
2022-02-23 04:42:41
linux 下python多线程递归复制文件夹及文件夹中的文件
2021-06-28 03:27:44
Pytorch修改ResNet模型全连接层进行直接训练实例
2023-06-07 03:49:28
应用技术:如何通过SQLyog分析MySQL数据库
2009-03-25 16:53:00
Linux CentOS下docker部署Asp.Net Core(.Net6)
2024-06-05 15:44:00
![](https://img.aspxhome.com/file/2023/4/122834_0s.jpg)
python中numpy 常用操作总结
2021-01-10 05:01:57
SQL Server存储过程中编写事务处理的方法小结
2024-01-15 15:24:24
浅谈django不使用restframework自定义接口与使用的区别
2023-11-24 09:44:02
python eval 转换k m到乘法计算的操作
2023-10-30 03:26:04
![](https://img.aspxhome.com/file/2023/8/99158_0s.png)
初学ASP编程易犯的一个错误要注意
2008-11-07 15:08:00
Pandas中根据条件替换列中的值的四种方式
2022-07-25 00:27:38
![](https://img.aspxhome.com/file/2023/1/79751_0s.png)