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.构造 ...
随机推荐
- Hibernate学习笔记(三)—— Hibernate的事务控制
Hibernate是对JDBC的轻量级封装,其主要功能是操作数据库.在操作数据库过程中,经常会遇到事务处理的问题,接下来就来介绍Hibernate中的事务管理. 在学习Hibernate中的事务处理之 ...
- Android 连接服务器,并进行相关操作
1.连接服务器 (1)直接使用WINDOWS自带的远程桌面连接 win+R调出DOS操作窗口,输入mstsc.exe 点击确定,进入如下界面: 点击连接,输入用户名和密码登录,电脑会进入服务器界面.
- 基于vue-cli搭建路飞
一.项目搭建 1. 首先进入到项目要保存的文件夹,然后执行命令如下命令初始化项目 vue init webpack lufei 2. 命令执行后,除了第一个填一下项目名称,其他的一路选no,这样建立的 ...
- 剑指offer——面试题6:从尾到头打印链表
#include"iostream" #include"stdio.h" #include"stack" using namespace s ...
- Lucene初识
1.概述 1.1 Lucene是apache软件基金会4 jakarta项目组的一个子项目: 是一个开放源代码的全文检索引擎工具包: 但它不是一个完整的全文检索引擎,而是一个全文检索引擎的架构,提供了 ...
- elastic 集群安装
Elastic Search 安装和配置 1.下载 wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6. ...
- 三大视频网站Url的处理保存(视频和图片二选一操作)
前台Js // 视频处理 var textVideoLink=$("input[name='textVideoLink']").val(); // 去除所有有的引号和空格 var ...
- [转]ClassPath是什么
from: https://my.oschina.net/GivingOnenessDestiny/blog/603505 classpath 是什么classpath实际上就是编译后的 以 clas ...
- Navicat Premium v12.0.23.0 破解教程x86,x64通用,手动破解
教程来源于:吾爱破解网站 ----------更新线----------- 2018.01.23 Navicat Premium v12.0.23.0 测试破解依然有效 ----------更新线-- ...
- java中的各种修饰符作用范围
访问修饰符: private 缺省 protected public 作用范围: 访问修饰符\作用范围 所在类 同一包内其他类 其他包内子类 其他包内非子类 private 可以访问 不可以 不可以 ...