3 种进度条 -- 记录

时间:2021-02-22 11:47:27   收藏:0   阅读:0

 

第一种:普通进度条

# 普通进度条

import sys
import time

def test():
    for i in range(1, 101):
        print(\r, end=‘‘)
        print(Download progress: {}%.format(i),  * (i//2), end=‘‘)
        sys.stdout.flush()
        time.sleep(0.05)

test()

技术图片

 

 

 

 

 

 

第二种:带时间的进度条

# 带时间进度条

import time

def test():
    start = time.perf_counter()
    for i in range(60+1):
        a = * * i
        b = . * (60 - i)
        c = (i / 60) * 100
        dur = time.perf_counter() - start
        print(\r{:^3.0f}%[{} - > {}]{:.2f}s.format(c, a, b, dur), end=‘‘)
        time.sleep(0.1)

test()

 

技术图片

 

 

 

 

第三种:tqdm进度条

from tqdm import tqdm
from time import sleep

for i in tqdm(range(100)):
    sleep(0.1)

技术图片

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!