首页 > 技术文章 > Python之进度条

huangshiyu13 2018-01-24 19:43 原文

pip install tqdm

 

from tqdm import tqdm,trange
import time

for char in tqdm(['a','b','c','d']):
    time.sleep(0.2)
for i in trange(4):
    time.sleep(0.2)

for i in trange(10):
    time.sleep(0.2)

pbar = tqdm(["a", "b", "c", "d"])
for char in pbar:
    time.sleep(0.8)
    pbar.set_description("Processing %s" % char)

with tqdm(total=100) as pbar:
    for i in range(10):
        time.sleep(1)
        pbar.update(10)

 

推荐阅读