Python tqdm show progress bar
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的更多相关文章
- unity3d插件Daikon Forge GUI 中文教程5-高级控件listbox和progress bar的使用
3.3.listbox列表框 Atlas 图集: 下面应用到的精灵都是在这里的. ListBox中的内容: 背景精灵 图片的主颜色 Padding边距 Scrollbar 滚动条对象的预制体或者对象, ...
- Circular progress bar in Unity 3D
Circular progress bar in Unity 3D - UnityScripthttp://stackoverflow.com/questions/22662706/circular- ...
- 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 ...
- unity3d插件Daikon Forge GUI 中文教程-5-高级控件listbox和progress bar的使用
(游戏蛮牛首发)大家好我是孙广东.官网提供了专业的视频教程http://www.daikonforge.com/dfgui/tutorials/,只是是在youtube上,要观看是须要FQ的. 只是教 ...
- C#控制台进度条(Programming Progress bar in C# Consle application)
以下代码从Stack Overflow,觉得以后会用到就收藏一下,我是辛勤的搬运工,咿呀咿呀哟- 1.showing percentage in .net console application(在. ...
- 打印进度条——(progress bar才是专业的)
# 打印进度条——(progress bar是专业的) import time for i in range(0,101,2): time.sleep(0.1) char_num = i//2 #打印 ...
- WPF 4 开发Windows 7 任务栏(Overlay Icon、Thumbnail Toolbar、Progress Bar)
原文:WPF 4 开发Windows 7 任务栏(Overlay Icon.Thumbnail Toolbar.Progress Bar) 在上一篇我们介绍了如何在WPF 4 中开发Wind ...
- 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 ...
- Showing progress bar in a status bar pane
在工具卡显示进度条,原文链接:http://www.codeproject.com/Articles/35/Showing-progress-bar-in-a-status-bar-pane 1.构造 ...
随机推荐
- C#.net地址传参汉字乱码解决方案
C#.net地址传参汉字乱码解决方案 web.config文件: <system.web> <globalization requestEncoding="GB2312 ...
- Wannafly挑战赛26-F. msc的棋盘(模型转化+dp)及一类特殊的网络流问题
题目链接 https://www.nowcoder.com/acm/contest/212/F 题解 我们先考虑如果已知了数组 \(\{a_i\}\) 和 \(\{b_i\}\),如何判断其是否合法. ...
- Codeforces Round #549 (Div. 2) Solution
传送门 A.The Doors 看懂题目就会写的题 给一个 $01$ 序列,找到最早的位置使得 $0$ 或 $1$ 已经全部出现 #include<iostream> #include&l ...
- 去掉小程序button元素的边框
button::after { display:none }
- 119th LeetCode Weekly Contest Largest Perimeter Triangle
Given an array A of positive lengths, return the largest perimeter of a triangle with non-zero area, ...
- Codeforces - 570D 离散DFS序 特殊的子树统计 (暴力出奇迹)
题意:给定一棵树,树上每个节点有对应的字符,多次询问在\(u\)子树的深度为\(d\)的所有节点上的字符任意组合能否凑成一个回文串 把dfs序存储在一个二维线性表中,一个维度记录字符另一个维度记录深度 ...
- Notepad++中F3直接搜索选中文字
用了Notepad++好久了,一直被"F3不能直接搜索选中文字"困扰.毕竟以前习惯UltraEdit的这种操作,很便捷.今天突然发现原来Notepad++快捷键里可以修改这个功能, ...
- css3 渐变色
Firefox可以使用角度来设定渐变的方向,而webkit只能使用x和y轴的坐标. 渐变可以创建类似于彩虹的效果,低版本的浏览器使用图片来实现,CSS3将会轻松实现网页渐变效果 粘贴代码 <di ...
- V1-Team Scrum Meeting 博客汇总
V1-Team Scrum Meeting 博客汇总 计划文档 功能规格说明书 技术规格说明书 项目分解 贡献分配规则 一.Alpha阶段 第一次 Scrum Meeting 第二次 Scrum Me ...
- c++读取list.txt中每行的字符串以及写入二进制文件
#include <fstream> #include <fstream> string path = ""; FILE* fp = fopen(path. ...