使用方法一: 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的使用方法的更多相关文章

  1. Python进度条模块tqdm实现任务进度可视化

    一.前言 tqdm 是一个易用性强.扩展性高的 Python 进度条库,可以在 Python 长循环中添加一个进度提示信息,我们只需要封装任意的迭代器 tqdm(iterator) 即可. 二.安装 ...

  2. python3.4学习笔记(八) Python第三方库安装与使用,包管理工具解惑

    python3.4学习笔记(八) Python第三方库安装与使用,包管理工具解惑 许多人在安装Python第三方库的时候, 经常会为一个问题困扰:到底应该下载什么格式的文件?当我们点开下载页时, 一般 ...

  3. Python第三方库matplotlib(2D绘图库)入门与进阶

    Matplotlib 一 简介: 二 相关文档: 三 入门与进阶案例 1- 简单图形绘制 2- figure的简单使用 3- 设置坐标轴 4- 设置legend图例 5- 添加注解和绘制点以及在图形上 ...

  4. Python第三方库资源

    [转载]Python第三方库资源   转自:https://weibo.com/ttarticle/p/show?id=2309404129469920071093 参考:https://github ...

  5. 3、python第三方库的安装方式

    在学习Python过程中,经常要用到很多第三方库,面对各种不同情况,Python为我们提供了多种安装方法,这里主要介绍三种 方法:pycharm在线安装.pip在线安装(强烈推荐).离线安装. 方式一 ...

  6. 常用Python第三方库 简介

    如果说强大的标准库奠定了python发展的基石,丰富的第三方库则是python不断发展的保证,随着python的发展一些稳定的第三库被加入到了标准库里面,这里有6000多个第三方库的介绍:点这里或者访 ...

  7. PyCharm 如何安装python第三方库及插件

    一.如何安装python第三方库: 1.有一个专门可下载安装第三方库的网址: http://www.lfd.uci.edu/~gohlke/pythonlibs/ Ctrl+f 搜索要下载的第三方库, ...

  8. python 第三方库

    1.tqdm 进度条 from tqdm import tqdm for i in tqdm(range(10000)): pass 2.fire 自动创建命令行接口(command line int ...

  9. 【Python基础】安装python第三方库

    pip命令行安装(推荐) 打开cmd命令行 安装需要的第三方库如:pip install numpy 在安装python的相关模块和库时,我们一般使用“pip install  模块名”或者“pyth ...

随机推荐

  1. Python四大主流网络编程框架

    目前的4种主流Python网络框架:Django.Tornado.Flask.Twisted.

  2. HTML5-form表单

    什么是表单? 01.获取用户的输入  ==>收集数据 02.将用户的输入发送到服务器   ==>与服务器进行交互 相关属性: action:我们收集完用户的信息之后,需要提交的服务器地址 ...

  3. DATEDIFF 和 DATEADD

    /* DATEDIFF函数计算两个日期之间的小时.天.周.月.年等时间间隔总数 语法 DATEDIFF(interval, date1, date2[, firstdayofweek[, firstw ...

  4. [JSBSim]基于winsocket2的TCP\UDP使用例子

    TCP部分: 参考:http://blog.csdn.net/sbfksmq/article/details/50808863 另附:linux下的tcp/udp参考:https://www.cnbl ...

  5. [库][c++]tinyxml2使用小结

    参考:http://blog.csdn.net/educast/article/details/12908455 1.配置TinyXML2 去这里把项目弄下来,然后解压,我们之需要里面的tinyxml ...

  6. ubuntu配置zsh和oh-my-zsh

    1安装zsh sudo apt-get install -y zsh chsh -s /bin/zsh 2安装oh-my-zsh $ sh -c "$(curl -fsSL https:// ...

  7. [.NET开发] C#实现发送手机验证码功能

    之前不怎么了解这个,一直以为做起来很复杂. 直到前两天公司要求要做这个功能. 做了之后才发现 这不过就是一个POST请求就能实现的东西.现在给大家分享一下,有不足之处还请多多指教. 废话不多说 直接上 ...

  8. Gluttony CodeForces - 892D (构造,思维)

    题面: You are given an array a with n distinct integers. Construct an array b by permuting a such that ...

  9. OC ARC之基本使用(代码分析)

    // // main.m // 01-arc的基本使用 // // Created by apple on 13-8-11. // Copyright (c) 2013年 itcast. All ri ...

  10. cas AssertionThreadLocalFilter

    AssertionThreadLocalFilter AssertionThreadLocalFilter作用很简单,就是将Assertion绑定到ThreadLocal. ThreadLocal 无 ...