#! /usr/bin/env python
# -*- coding: utf-8 -*-#
# -------------------------------------------------------------------------------
# Name: demo01
# Author: yunhgu
# Date: 2021/7/5 10:19
# Description:
# -------------------------------------------------------------------------------
from time import sleep
from tqdm import tqdm
from progress.bar import IncrementalBar
from alive_progress import alive_bar
# 这里同样的,tqdm就是这个进度条最常用的一个方法
# 里面存一个可迭代对象
def process_bar():
for i in tqdm(range(1, 500)):
# 模拟你的任务
sleep(0.01)
sleep(0.5)
def process_bar01():
mylist = [1, 2, 3, 4, 5, 6, 7, 8]
bar = IncrementalBar('Countdown', max=len(mylist))
for item in mylist:
bar.next()
sleep(1)
def process_bar02():
# retrieve your set of items
items = range(1000)
# declare your expected total
with alive_bar(len(items)) as bar:
# iterate as usual
for item in items:
# process each item
bar()
sleep(0.1)
if __name__ == '__main__':
process_bar()
# process_bar01()
# process_bar02()