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. P3704 [SDOI2017]数字表格 (莫比乌斯反演)

    [题目链接] https://www.luogu.org/problemnew/show/P3704 [题解] https://www.luogu.org/blog/cjyyb/solution-p3 ...

  2. 【算法笔记】B1054 求平均值

    atof(str)字符串转换浮点数 #include<bits/stdc++.h> using namespace std; bool isLegal(char *s){ ; ]=='-' ...

  3. HDU-6341 Problem J. Let Sudoku Rotate(dfs 剪枝)

    题目:有一个4*4*4*4的数独,每一横每一竖每一个小方块中都无重复的字母,即都为0-9,A-F..有一个已经填好的数独,若干个4*4的方块被逆时针拧转了若干次,问拧转回来至少需要多少次. 分析:很明 ...

  4. webstorm识别 ftl文件

    webstorm对freemaker语法是原生支持的,也不需要安装什么插件,你可以直接在webstorm新建个File Types即可 file->settings->file types ...

  5. VBS添加Windows登陆账号

    Set o=CreateObject( "Shell.Users" ) Set z=o.create("test") z.changePassword &quo ...

  6. python 函数的作用域,闭包函数的用法

    一.三元表达式 if条件成功的值    if  条件   else else条件成功的值 #if条件成立的结果 if 条件 else else条件成立的结果 # a = 20 # b = 10 # c ...

  7. Python 垃圾回收机制(转)

    概述 python采用的是引用计数机制为主,标记-清除和分代收集两种机制为辅的策略. 引用计数 Python语言默认采用的垃圾收集机制是『引用计数法 Reference Counting』,该算法最早 ...

  8. Oracle RAC集群删除节点

    一,节点环境 [root@node1 ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost ...

  9. oracle 单实例DG(闪回技术四)

    一,flashback Oracle Flashback技术是一组数据库特性,它可以让你查看数据库对象的过去状态,或者将数据库对象返回到以前的状态,而无需使用基于时间点的介质恢复.根据数据库的变化,闪 ...

  10. Android应用程序组件之间的通信Intent和IntentFilter

    Android应用程序的基本组件,这些基本组建除了Content Provider之外,几乎全部都是依靠Intent对象来激活和通信的. 下面介绍Intent类,并通过例子来说明Intent一般用法 ...