Python 第三方库 进度条模块 tqdm的使用方法
使用方法一: tqdm
tqdm(list)方法可以传入任意一种list,比如数组,同时tqdm中不仅仅可以传入list, 同时可以传入所有带len方法的可迭代对象,这里只以list对象为例:
from tqdm import tqdm
from time import sleep for i in tqdm(range(1000)):
sleep(0.1)

或是:
from tqdm import tqdm
from time import sleep for i in tqdm(['a', 'b', 'c', 'd', 'e']):
sleep(0.1)
使用方法二: trange
trange(i) 是 tqdm(range(i)) 的等价写法
from tqdm import trange
from time import sleep for i in trange(1000):
sleep(1)
使用方法三: 改变循环信息
from tqdm import trange, tqdm
from time import sleep pbar = tqdm(range(1000))
for char in pbar:
pbar.set_description("Processing %s" % char)
sleep(1)
或是:
from tqdm import trange, tqdm
from time import sleep pbar = trange(1000)
for char in pbar:
pbar.set_description("Processing %s" % char)
sleep(1)
或是:
from tqdm import trange, tqdm
from time import sleep for i in tqdm(range(100), desc='1st loop'):
sleep(1)


实际操作中发现 desc(str) 比 set_description 好用。
使用方法四 手动控制进度:
import time
from tqdm import tqdm # 一共200个,每次更新10,一共更新20次
with tqdm(total=200) as pbar:
for i in range(20):
pbar.update(10)
time.sleep(0.1)
或是:
pbar = tqdm(total=200)
for i in range(20):
pbar.update(10)
time.sleep(0.1)
# close() 不要也没出问题
pbar.close()
Python 第三方库 进度条模块 tqdm的使用方法的更多相关文章
- Python进度条模块tqdm实现任务进度可视化
一.前言 tqdm 是一个易用性强.扩展性高的 Python 进度条库,可以在 Python 长循环中添加一个进度提示信息,我们只需要封装任意的迭代器 tqdm(iterator) 即可. 二.安装 ...
- python3.4学习笔记(八) Python第三方库安装与使用,包管理工具解惑
python3.4学习笔记(八) Python第三方库安装与使用,包管理工具解惑 许多人在安装Python第三方库的时候, 经常会为一个问题困扰:到底应该下载什么格式的文件?当我们点开下载页时, 一般 ...
- Python第三方库matplotlib(2D绘图库)入门与进阶
Matplotlib 一 简介: 二 相关文档: 三 入门与进阶案例 1- 简单图形绘制 2- figure的简单使用 3- 设置坐标轴 4- 设置legend图例 5- 添加注解和绘制点以及在图形上 ...
- Python第三方库资源
[转载]Python第三方库资源 转自:https://weibo.com/ttarticle/p/show?id=2309404129469920071093 参考:https://github ...
- 3、python第三方库的安装方式
在学习Python过程中,经常要用到很多第三方库,面对各种不同情况,Python为我们提供了多种安装方法,这里主要介绍三种 方法:pycharm在线安装.pip在线安装(强烈推荐).离线安装. 方式一 ...
- 常用Python第三方库 简介
如果说强大的标准库奠定了python发展的基石,丰富的第三方库则是python不断发展的保证,随着python的发展一些稳定的第三库被加入到了标准库里面,这里有6000多个第三方库的介绍:点这里或者访 ...
- PyCharm 如何安装python第三方库及插件
一.如何安装python第三方库: 1.有一个专门可下载安装第三方库的网址: http://www.lfd.uci.edu/~gohlke/pythonlibs/ Ctrl+f 搜索要下载的第三方库, ...
- python 第三方库
1.tqdm 进度条 from tqdm import tqdm for i in tqdm(range(10000)): pass 2.fire 自动创建命令行接口(command line int ...
- 【Python基础】安装python第三方库
pip命令行安装(推荐) 打开cmd命令行 安装需要的第三方库如:pip install numpy 在安装python的相关模块和库时,我们一般使用“pip install 模块名”或者“pyth ...
随机推荐
- 《剑指offer》第三十二题(不分行从上往下打印二叉树)
// 面试题32(一):不分行从上往下打印二叉树 // 题目:从上往下打印出二叉树的每个结点,同一层的结点按照从左到右的顺序打印. #include <iostream> #include ...
- Spring Boot入门——文件上传与下载
1.在pom.xml文件中添加依赖 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="ht ...
- 554C - Kyoya and Colored Balls
554C - Kyoya and Colored Balls 思路:组合数,用乘法逆元求. 代码: #include<bits/stdc++.h> using namespace std; ...
- js-Client-side web APIs
APIs https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Client-side_web_APIs/ 简介: 应用程序接口(API) ...
- 插件Vue.Draggable(5000🌟)
安装资源库:从Vue资源:https://github.com/vuejs/awesome-vue下载 Libraries/UI Components/Form/Drag and Drop yarn ...
- React 介绍
ttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind The sm ...
- Krapno 1
All krpano software can be downloaded and tested for free - without any functional limitation.For us ...
- hdu3294 manacher
One day, sailormoon girls are so delighted that they intend to research about palindromic strings. O ...
- 秒杀多线程第三篇 原子操作 Interlocked系列函数
上一篇<多线程第一次亲密接触 CreateThread与_beginthreadex本质区别>中讲到一个多线程报数功能.为了描述方便和代码简洁起见,我们可以只输出最后的报数结果来观察程序是 ...
- OC Copy基本使用(深拷贝和浅拷贝)
首先,什么是copy? Copy的字面意思是“复制”.“拷贝”,是一个产生副本的过程. 常见的复制有:文件复制,作用是利用一个源文件产生一个副本文件. 特点:1.修改源文件的内容,不会影响副本文件: ...