zoukankan      html  css  js  c++  java
  • 3 种进度条 -- 记录

    第一种:普通进度条

    # 普通进度条
    
    import sys
    import time
    
    def test():
        for i in range(1, 101):
            print('
    ', 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('
    {:^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)

  • 相关阅读:
    取球问题
    汉字首字母
    上三角
    循环小数
    拓扑排序
    倒水
    equals方法使用技巧
    Java库中的集合
    win10安装Redis方法以及基本配置
    c、c++函数随机
  • 原文地址:https://www.cnblogs.com/shiyixirui/p/14419970.html
Copyright © 2011-2022 走看看