# pip install tqdm # 进度条 from tqdm import tqdm # 时间处理 import time
>>> # 循环进度使用进度条展示 >>> for i in tqdm(range(10)): ... # 停留1秒 ... time.sleep(1) ... 10%|████████▎ | 1/10 [00:01<00:09, 1 20%|████████████████▌ | 2/10 [00:02<0 30%|████████████████████████▉ | 3/10 40%|█████████████████████████████████▏ 50%|█████████████████████████████████████████▌ 60%|█████████████████████████████████████████████████▊ 70%|█████████████████████████████████████████████████████████ 80%|█████████████████████████████████████████████████████████ 90%|█████████████████████████████████████████████████████████ 100%|█████████████████████████████████████████████████████████ █████████████████████████| 10/10 [00:10<00:00, 1.01s/it]
…
# >>> list_ = tqdm(["1","2","3","4"]) # >>> for process in list_: | 0/4 [00:00<?, ?it/s] # ... time.sleep(1) # ... list_.set_description("处理过程: %s"%process) # ... # 处理过程: 4: 100%|██████████| 4/4 [00:04<00:00, 1.02s/it]