- ubuntu12.04环境下使用kvm ioctl接口实现最简单的虚拟机
- Ubuntu 通过无线网络安装Ubuntu Server启动系统后连接无线网络的方法
- 在Ubuntu上搭建网桥的方法
- ubuntu 虚拟机上网方式及相关配置详解
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章Python使用progressbar模块实现的显示进度条功能由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
本文实例讲述了Python使用progressbar模块实现的显示进度条功能。分享给大家供大家参考,具体如下:
progressbar安装:
1
|
pip install progressbar
|
用法一 。
1
2
3
4
5
6
7
8
9
|
# -*- 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% |#########################################################################| 。
用法二 。
1
2
3
4
5
6
7
8
9
10
11
12
|
# -*- 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% |#############################################################################| 。
用法三 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
# -*- 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() :显示已用时间 。
希望本文所述对大家Python程序设计有所帮助.
原文链接:https://blog.csdn.net/dcrmg/article/details/79525167 。
最后此篇关于Python使用progressbar模块实现的显示进度条功能的文章就讲到这里了,如果你想了解更多关于Python使用progressbar模块实现的显示进度条功能的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
我的应用程序中有一个 ProgressBar 小部件,无论我做什么,它总是显示为粗橙色(2.x 样式)而不是细蓝色(4.x 样式) . 项目构建目标设置为 Google API 4.0.3(API 级
private static ProgressDialog pDialog; pDialog = new ProgressDialog(activity); pDialog.setIndetermin
我试图让 TalkBack 阅读进度条上的进度,但运气不佳。关于如何获取该信息以便 TalkBack 可以说出来的任何想法。 谢谢 公共(public)类 MainActivity 扩展 Activi
进度条总是返回null public void calcola(View view) { final Dialog myDialog = new Dialog(this);
我正在尝试用选取框样式测试进度条,但没有成功 private void Form1_Load(object sender, EventArgs e) { Applica
我使用以下 Ruby 片段下载 a 8.9MB file . require 'open-uri' require 'net/http' require 'uri' def http_download
我为操作栏按钮尝试了两种不同的进度条样式,通过 refreshMenuItem.setActionView(R.layout.actionbar_indeterminate_progress); ac
每当我输入 fragment 时,我都会看到几秒钟的空白,然后 WebView 中的网页就会出现。 ProgressBar 好像没有显示。 这是我的 XML 文件,用于 WebView 和 Progr
我的包依赖于一个名为 progressbar 的包。有一个bug in progressbar 2.3导致Python>3.3安装失败,因此我安装了latest git repo from this
任何默认的 ProgressBar 都有一个 ClipDrawable 级别,例如,一个绿色的 Drawable 在我的设备上填充灰色背景,在其他设备上填充黄色。 我的问题:当进度小于最大值时,是否可
这是随意的原型(prototype)代码,因此我尝试了我认为应该有效的方法,如果没有,则在谷歌上搜索,然后在仔细阅读类似问题后在这里提问。 我的 Shell 中有以下标记看法:
要在执行查询时显示 ProgressBar,我使用以下代码: if not Query1.Prepared then Query1.Prepare; Query1.Open; ProgressBa
我有三个类,例如 View 、逻辑、 Controller 。 class View{ Progressbutton pb; void start animation(){
我正在用 C#/WPF(.Net 框架 4.0)编写一个应用程序。我遇到的一件事是如何在应用程序非常繁忙时更新控件(如果可能)。我想我只是在努力尝试我在网上找到的东西来让它工作(而且在极少数情况下它会
要在执行查询时显示 ProgressBar,我使用以下代码: if not Query1.Prepared then Query1.Prepare; Query1.Open; ProgressBa
已关闭。此问题不符合 Stack Overflow guidelines 。目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 已关闭 3 年前。 奥 git _a
我创建了一个 ping 程序来 ping 5 服务器。如何在进度运行时让进度条运行。当 ping 完成时,进度条将为 100% private void btnGetstatusActionPer
我想在流程完成后在 PrimeFaces 上隐藏一个进度条。我认为没有必要在不工作时显示进度条。 html代码:
我想添加JProgressBar,它将在下载文件的程序中填充。 第三个问题是如何使进度条在 setValue 中添加正确的金额(例如:当它下载最后一个文件时,JPB 将完成)。 请注意,要下载的文件数
给定一个变量 N,反射(reflect)秒数,我想要一个 jQueryUI Progressbar顺利地从空更新到反射(reflect)该时间段内的完成。 换句话说,我想要一个显示进度条的functi
我是一名优秀的程序员,十分优秀!