progressbar安装:

pip install progressbar

用法一

# -*- coding=utf-8 -*-

import time
from progressbar import * total = 1000 def dosomework():
time.sleep(0.01) progress = ProgressBar()
for i in progress(range(1000)):
dosomework()

显示效果:

5% |###                                                                      |
100% |#########################################################################|

用法二

# -*- coding=utf-8 -*-

from __future__ import division

import sys, time
from progressbar import * total = 1000 def dosomework():
time.sleep(0.01) pbar = ProgressBar().start()
for i in range(1000):
pbar.update(int((i / (total - 1)) * 100))
dosomework()
pbar.finish()

显示效果:

39% |##############################                                               |
100% |#############################################################################|

用法三

# -*- coding=utf-8 -*-

import  time
from progressbar import * total = 1000 def dosomework():
time.sleep(0.01) widgets = ['Progress: ',Percentage(), ' ', Bar('#'),' ', Timer(),
' ', ETA(), ' ', FileTransferSpeed()]
pbar = ProgressBar(widgets=widgets, maxval=10*total).start()
for i in range(total):
# do something
pbar.update(10 * i + 1)
dosomework()
pbar.finish()

显示效果:

Progress:   3% |###                                                                                | Elapsed Time: 0:00:15 ETA: 0:09:02 919.67  B/s
Progress: 100% |###################################################################################| Elapsed Time: 0:10:10 Time: 0:10:10 917.42 B/s

widgets可选参数含义:

  • 'Progress: ' :设置进度条前显示的文字
  • Percentage() :显示百分比
  • Bar('#') : 设置进度条形状
  • ETA() : 显示预计剩余时间
  • Timer() :显示已用时间

最新文章

  1. 如何给GridView添加网格
  2. ppp数据帧的格式
  3. 我是如何用Go语言搭建自己的博客的
  4. MVC5 + EF6 + Bootstrap3 (14) 分部视图PartialView
  5. Runtime运行时的那点事儿
  6. poj3692_Kindergarten
  7. 设置用户sudo -s拥有root权限
  8. Hibernate四 批量处理
  9. zsh中home键失灵问题
  10. 【转】Python操作MongoDB数据库
  11. ispriter自动构建css-sprite
  12. jzoj5925
  13. SQL Server 数据库存储过程实例
  14. NGUI诡异的drawCall
  15. Servlet.service() for servlet UserServlet threw exception java.lang.NullPointerException 空指针异常
  16. asp.net mvc 上传图片 摘自mvc 高级编程第311页
  17. iOS开发~制作同时支持armv7,armv7s,arm64,i386,x86_64的静态库.a以及 FrameWork 的创建
  18. Linux系统下安装Redis和Redis集群配置
  19. Vue脚手架开发使用sass
  20. LocalReport Print with C# C#打印RDLC

热门文章

  1. 树梅派配置ad-hoc网络
  2. mybatis中的懒加载
  3. Android studio 运行模拟器报:Application Installation Failed
  4. 决策树的剪枝,分类回归树CART
  5. Learning Perl 第九章习题第二题
  6. 数据库访问辅助类SqlHelper
  7. tp5---auth权限搭建2
  8. thinkphp3.2.3 + nginx 配置二级域名
  9. Python模块学习之解决selenium的“can't access dead object”错误
  10. Java String类为什么不可变?