最全的Python进度条展示程序方案
a = 'abc, 123, abc, 123, abc'
b = a.replace('abc','')
print(b)#2018-02-13 10:53:46 February Tuesday the 07 week, the 044 day SZ SSMR
#使用tqdm进行进度条显示
from tqdm import tqdm
from time import sleep
for i in tqdm(range(10)):sleep(0.5)0%| | 0/10 [00:00<?, ?it/s]10%|█ | 1/10 [00:00<00:04, 2.00it/s]20%|██ | 2/10 [00:01<00:04, 2.00it/s]30%|███ | 3/10 [00:01<00:03, 2.00it/s]40%|████ | 4/10 [00:02<00:03, 2.00it/s]50%|█████ | 5/10 [00:02<00:02, 2.00it/s]60%|██████ | 6/10 [00:03<00:02, 2.00it/s]70%|███████ | 7/10 [00:03<00:01, 2.00it/s]80%|████████ | 8/10 [00:04<00:01, 2.00it/s]90%|█████████ | 9/10 [00:04<00:00, 2.00it/s]
100%|██████████| 10/10 [00:05<00:00, 2.00it/s]
[Finished in 6.2s]#进度条方法:
#2018-02-13 10:53:42 February Tuesday the 07 week, the 044 day SZ SSMRimport time
N = 10
for i in range(N):print("进度:{0}%".format(round((i + 1) * 100 / N)), end="\r")time.sleep(0.1)进度:10%
进度:20%
进度:30%
进度:40%
进度:50%
进度:60%
进度:70%
进度:80%
进度:90%
进度:100%
[Finished in 1.6s]#2018-02-13 11:25:08 February Tuesday the 07 week, the 044 day SZ SSMR
# \r 默认表示将输出的内容返回到第一个指针,这样的话,后面的内容会覆盖前面的内容
import time
import sys
def main():for i in range(65,80):s="\r{name:s}".format(name=chr(i))time.sleep(0.05)sys.stdout.write(s) #不会有空行#print(s) #结果有空行main()A
B
C
D
E
F
G
H
I
J
K
L
M
N
O[Finished in 1.5s]#2018-02-13 11:25:02 February Tuesday the 07 week, the 044 day SZ SSMR
import sys, timefor i in range(10):sys.stdout.write('{0}/10\r'.format(i + 1))sys.stdout.flush()time.sleep(0.1)
1/10
2/10
3/10
4/10
5/10
6/10
7/10
8/10
9/10
10/10
[Finished in 1.6s]0000000000
111111111
22222222
3333333
444444
55555
6666
777
88
9
[Finished in 1.6s]#2018-02-13 11:26:22 February Tuesday the 07 week, the 044 day SZ SSMR
import sys, timefor i in range(10):sys.stdout.write(str(i) + '\n' )sys.stdout.flush()time.sleep(0.1)0
1
2
3
4
5
6
7
8
9
[Finished in 1.6s]#2018-02-13 11:28:42 February Tuesday the 07 week, the 044 day SZ SSMRimport time
N = 10
for i in range(N):print("进度:{0}%".format(round((i + 1) * 100 / N)), end="\r")time.sleep(0.01)进度:10%
进度:20%
进度:30%
进度:40%
进度:50%
进度:60%
进度:70%
进度:80%
进度:90%
进度:100%
[Finished in 1.2s]
#2018-02-13 13:21:01 February Tuesday the 07 week, the 044 day SZ SSMR进度:10%,已耗时:0.0s,预计剩余时间:0.0s
进度:20%,已耗时:0.01s,预计剩余时间:0.04s
进度:30%,已耗时:0.02s,预计剩余时间:0.05s
进度:40%,已耗时:0.03s,预计剩余时间:0.04s
进度:50%,已耗时:0.04s,预计剩余时间:0.04s
进度:60%,已耗时:0.05s,预计剩余时间:0.03s
进度:70%,已耗时:0.06s,预计剩余时间:0.03s
进度:80%,已耗时:0.07s,预计剩余时间:0.02s
进度:90%,已耗时:0.08s,预计剩余时间:0.01s
进度:100%,已耗时:0.09s,预计剩余时间:-0.0s
[Finished in 0.7s]import time
N = 10
st = time.clock()
for i in range(N):p = round((i + 1) * 100 / N) #round() 方法返回浮点数x的四舍五入值duration = round(time.clock() - st, 2)remaining = round(duration * 100 / (0.01 + p) - duration, 2)print("进度:{0}%,已耗时:{1}s,预计剩余时间:{2}s".format(p, duration, remaining), end = '\r')time.sleep(0.01)进度:10%,已耗时:0.0s,预计剩余时间:0.0s
进度:20%,已耗时:0.01s,预计剩余时间:0.04s
进度:30%,已耗时:0.02s,预计剩余时间:0.05s
进度:40%,已耗时:0.03s,预计剩余时间:0.04s
进度:50%,已耗时:0.04s,预计剩余时间:0.04s
进度:60%,已耗时:0.05s,预计剩余时间:0.03s
进度:70%,已耗时:0.06s,预计剩余时间:0.03s
进度:80%,已耗时:0.07s,预计剩余时间:0.02s
进度:90%,已耗时:0.08s,预计剩余时间:0.01s
进度:100%,已耗时:0.09s,预计剩余时间:-0.0s
[Finished in 0.7s]#!/usr/bin/python
import timedef procedure():time.sleep(2.5)# measure process time
t0 = time.clock()
procedure()
print(time.clock() - t0, "seconds process time")# measure wall time
t0 = time.time()
procedure()
print(time.time() - t0, "seconds wall time")import timeprint("time.time(): %f " % time.time())
print(time.localtime( time.time() ))
print(time.asctime( time.localtime(time.time()) ))time.time(): 1518500152.606349
time.struct_time(tm_year=2018, tm_mon=2, tm_mday=13, tm_hour=13, tm_min=35, tm_sec=52, tm_wday=1, tm_yday=44, tm_isdst=0)
Tue Feb 13 13:35:52 2018
[Finished in 0.7s]import time
import progressbar
p = progressbar.ProgressBar()
N = 10
for i in p(range(N)):time.sleep(0.01)
#2018-02-13 13:51:06 February Tuesday the 07 week, the 044 day SZ SSMR
import time
import progressbar
p = progressbar.ProgressBar()
N = 1000
p.start(N)
for i in range(N):time.sleep(0.01)p.update(i+1)
p.finish()#2018-02-13 13:51:13 February Tuesday the 07 week, the 044 day SZ SSMRimport time
import progressbar
bar = progressbar.ProgressBar(widgets=[' [', progressbar.Timer(), '] ',progressbar.Percentage(),' (', progressbar.ETA(), ') ',
])
for i in bar(range(1000)):time.sleep(0.01)'Timer', # 计时器
'ETA', # 预计剩余时间
'AbsoluteETA', # 预计结束的绝对时间,耗时很长时使用较方便
'Percentage', # 百分比进度,30%
'SimpleProgress', # 计数进度,300/1000
'Counter', # 单纯计数
'Bar' # “#”号进度条
#2018-02-13 13:51:33 February Tuesday the 07 week, the 044 day SZ SSMR
最全的Python进度条展示程序方案相关推荐
- python 全栈开发,Day36(作业讲解(大文件下载以及进度条展示),socket的更多方法介绍,验证客户端链接的合法性hmac,socketserver)...
先来回顾一下昨天的内容 黏包现象 粘包现象的成因 : tcp协议的特点 面向流的 为了保证可靠传输 所以有很多优化的机制 无边界 所有在连接建立的基础上传递的数据之间没有界限 收发消息很有可能不完全 ...
- 2019年的代码都写完了吗?不如做个Python进度条看看还剩多少
我们都知道,进度条是用来直观展示流程所需时间的优秀工具,以免我们担心流程会突然挂掉,而且我们可以用它来预测代码运行是否正常,借助进度条,每个人都能直观地看到脚本最新的进展情况. 如果你之前没用过进度条 ...
- 036_python的大文件下载以及进度条展示
复习 1.黏包现象 粘包现象的成因: tcp协议的特点,面向流的,为了保证可靠传输,所以有很多优化的机制. 无边界 所有在连接建立的基础上传递的数据之间没有界限. 收发消息很有可能不完全相等. 缓存机 ...
- Python进度条库tqdm详解
tqdm模块是python进度条库, 主要分为两种运行模式 基于迭代对象运行: tqdm(iterator) importtimefromtqdmimporttqdm,trange#trange(i) ...
- python 进度条_python进度条
广告关闭 云服务器1核2G首年99年,还有多款热门云产品满足您的上云需求 功能说明:将程序执行进展情况按照百分比用进度条显示,适合用于文件传输进度显示运行环境:linux 6,python3. 6. ...
- python 进度条库 tqdm
转载出处 tqdm模块是python进度条库, 主要分为两种运行模式 基于迭代对象运行: tqdm(iterator) import time from tqdm import tqdm, trang ...
- python 进度条
python 进度条 tqdm库 #!/usr/bin/env python # -*- encoding: utf-8 -*- """ @Introduce : @Fi ...
- Python 进度条 tqdm
Python 进度条 tqdm from tqdm import tqdm import time#total参数设置进度条的总长度 pbar = tqdm(total=100) for i in r ...
- javascript --- [FormData的使用] 文件上传进度条展示 文件上传图片即使预览
1. 准备工作 因为要发送Ajax请求,而Ajax技术的运行需要网站环境,因此其中一个解决方案是,将页面作为网站的静态资源暴露出来,然后通过浏览器进行访问. 1.1 静态资源 使用express将pu ...
最新文章
- 学会动态丨中国人工智能学会重磅发布《2018人工智能产业创新评估白皮书》
- ul li前面的点怎么变大_亚马逊产品被投诉需要UL认证,该如何办理?
- Bzoj4818--Sdoi2017序列计数
- RocketMQ的Consumer详解之push和pull模式(长轮询)
- 在.NET Core中使用MEF
- 互联网晚报 | 10月5日 星期二 | 爱奇艺、腾讯、优酷宣布取消超前点播;蜜雪冰城冲刺A股上市;吴京主演电影票房超200亿...
- 如何在ubuntu上用c++串口通信_让你搞懂PLC串口通讯和通讯接口,这东西估计没几个能说清楚~...
- 原生html冻结表头,CSS如何实现表头冻结效果
- 2021江西高考成绩小分查询,2021江西高考成绩查分时间
- sh脚本异常:/bin/sh^M:bad interpreter: No such file ...
- python代码换行快捷键_python中怎么代码换行
- ubuntu安装vasp_Ubuntu常用软件的安装
- NMAP Masscan python识别端口运行服务 常用命令速查表
- 静态代理和动态代理详解
- Linux命令大全(一)(详解)系统管理、系统设置及文档编辑
- 安卓原生系统_全球首个原生安卓车载系统实测!操作流畅 可跟手机媲美
- html如何删除网页边框,如何从HTML表中完全删除边框
- 发票查验|身份证实名认证增强版API开发文档
- Flink的批流统一:Ⅱ
- RK3399实际解码能力测试