tqdm can help to show a smart progress bar, and it is very easy to use, just wrap any iterable with tqdm(iterable), and you’re done!

the best way to learn is to read the official document: https://pypi.python.org/pypi/tqdm

i just copy the documents and add part of my understand.

Interable-based

Wrap tqdm() around any iterable:

text = ""
for char in tqdm(["a", "b", "c", "d"]):
text = text + char

trange(i) is a special optimised instance of tqdm(range(i)):

for i in trange(100):
pass

Instantiation outside of the loop allows for manual control over tqdm():

pbar = tqdm(["a", "b", "c", "d"])
for char in pbar:
pbar.set_description("Processing %s" % char)

Manual

Manual control on tqdm() updates by using a with statement:

with tqdm(total=100) as pbar:
for i in range(10):
pbar.update(10)

If the optional variable total (or an iterable with len()) is provided, predictive stats are displayed.

with is also optional (you can just assign tqdm() to a variable, but in this case don’t forget to del or close() at the end:

pbar = tqdm(total=100)
for i in range(10):
pbar.update(10)
pbar.close()

Parameters

there are other parameters to give detail settings.

class tqdm(object):
"""
Decorate an iterable object, returning an iterator which acts exactly
like the original iterable, but prints a dynamically updating
progressbar every time a value is requested.
""" def __init__(self, iterable=None, desc=None, total=None, leave=True,
file=sys.stderr, ncols=None, mininterval=0.1,
maxinterval=10.0, miniters=None, ascii=None, disable=False,
unit='it', unit_scale=False, dynamic_ncols=False,
smoothing=0.3, bar_format=None, initial=0, position=None,
postfix=None):

Python tqdm show progress bar的更多相关文章

  1. unity3d插件Daikon Forge GUI 中文教程5-高级控件listbox和progress bar的使用

    3.3.listbox列表框 Atlas 图集: 下面应用到的精灵都是在这里的. ListBox中的内容: 背景精灵 图片的主颜色 Padding边距 Scrollbar 滚动条对象的预制体或者对象, ...

  2. Circular progress bar in Unity 3D

    Circular progress bar in Unity 3D - UnityScripthttp://stackoverflow.com/questions/22662706/circular- ...

  3. Create a “% Complete” Progress Bar with JS Link in SharePoint 2013

    Create a “% Complete” Progress Bar with JS Link in SharePoint 2013 SharePoint 2013 has a lot new fea ...

  4. unity3d插件Daikon Forge GUI 中文教程-5-高级控件listbox和progress bar的使用

    (游戏蛮牛首发)大家好我是孙广东.官网提供了专业的视频教程http://www.daikonforge.com/dfgui/tutorials/,只是是在youtube上,要观看是须要FQ的. 只是教 ...

  5. C#控制台进度条(Programming Progress bar in C# Consle application)

    以下代码从Stack Overflow,觉得以后会用到就收藏一下,我是辛勤的搬运工,咿呀咿呀哟- 1.showing percentage in .net console application(在. ...

  6. 打印进度条——(progress bar才是专业的)

    # 打印进度条——(progress bar是专业的) import time for i in range(0,101,2): time.sleep(0.1) char_num = i//2 #打印 ...

  7. WPF 4 开发Windows 7 任务栏(Overlay Icon、Thumbnail Toolbar、Progress Bar)

    原文:WPF 4 开发Windows 7 任务栏(Overlay Icon.Thumbnail Toolbar.Progress Bar)      在上一篇我们介绍了如何在WPF 4 中开发Wind ...

  8. how to create a ring progress bar in web skills

    how to create a ring progress bar in web skills ring progress bar & circle progress bar canvas j ...

  9. Showing progress bar in a status bar pane

    在工具卡显示进度条,原文链接:http://www.codeproject.com/Articles/35/Showing-progress-bar-in-a-status-bar-pane 1.构造 ...

随机推荐

  1. BZOJ - 3489 KD树 范围计数 空间思维转换

    题意:给定数列\(a[1...n]\),\(Q\)次查询\([L,R]\)中只出现一次的最大值 这道题的做法比较劲.. 对每个元素构造三维空间的点\((i,pre[i],next[i])\),查询\( ...

  2. LightOJ - 1140 统计0的数位 数位DP

    注意以下几点: 搜索维度非约束条件的都要记录,否则大概率出错,比如_0 st参数传递和_0的互相影响要分辨清楚 num==-1就要返回0而不是1 #include<iostream> #i ...

  3. C# Autofac 的 BeanFactory

    using Autofac; using Microsoft.Practices.ServiceLocation; namespace Core.Common { /// <summary> ...

  4. Eclipse for PHP Developers 配置记录

    [原文发表在 http://osworld.sinaapp.com/post/18.html] 图都粘贴不了,直接看上面的原文吧~~~ 我比较懒,还是比较依赖IDE环境做开发的.所以为了学PHP开发, ...

  5. 第五次 Scrum Meeting

    第五次 Scrum Meeting 写在前面 会议时间 会议时长 会议地点 2019/4/9 22:00 30min 大运村1号楼6F 附Github仓库:WEDO 例会照片 工作情况总结(4.9) ...

  6. Docker容器日志查看与清理(亲测有效)

    https://blog.csdn.net/yjk13703623757/article/details/80283729 1. 问题 docker容器日志导致主机磁盘空间满了.docker logs ...

  7. python 爬虫系列08-同步斗图一波

    一波大图来袭 import requests from lxml import etree from urllib import request import os import re def par ...

  8. FZU 2213——Common Tangents——————【两个圆的切线个数】

    Problem 2213 Common Tangents Accept: 7    Submit: 8Time Limit: 1000 mSec    Memory Limit : 32768 KB ...

  9. nyoj 983 ——首尾相连数组的最大子数组和——————【最大子串和变形】

    首尾相连数组的最大子数组和 时间限制:1000 ms  |  内存限制:65535 KB 难度:4   描述 给定一个由N个整数元素组成的数组arr,数组中有正数也有负数,这个数组不是一般的数组,其首 ...

  10. 2018湖湘杯web、misc记录

    1.题目名 Code Check 打开题目,右键发现有id参数的url,简单base64解码以后发现不是明文,说明利用了其他的加密方式,那么应该会有具体的加密方式给我们,于是试试常见的文件泄露,可以发 ...