## 用tqdm和rich为固定路径和目标的python算法代码实现进度条

DechinPhy 2021-01-21 20:15:07

# `tqdm`进度条的使用方法与效果

``````# test_tqdm.py
from tqdm import trange
import time
for i in trange(10):
time.sleep(1)
``````

``````[dechin@dechin-manjaro progressbar]\$ python3 test_tqdm.py
40%|████████████████ | 4/10 [00:04<00:06, 1.00s/it]
``````

``````# test_tqdm.py
from tqdm import trange
import time
for i in trange(10):
for j in trange(10):
time.sleep(0.1)
``````

``````[dechin@dechin-20n2s01200 progressbar]\$ python3 test_tqdm.py
100%|███████████████████████████████████████| 10/10 [00:01<00:00, 9.88it/s]
100%|███████████████████████████████████████| 10/10 [00:01<00:00, 9.88it/s]
100%|███████████████████████████████████████| 10/10 [00:01<00:00, 9.88it/s]
30%|████████████ | 3/10 [00:03<00:07, 1.01s/it]
``````

# `rich`进度条的使用方法与效果

``````# test_rich.py
from rich.progress import track
import time
for i in track(range(15)):
time.sleep(1)
``````

``````[dechin@dechin-manjaro progressbar]\$ python3 test_rich.py
Working... ━━━━━━━━━━╸━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 27% 0:00:12
``````

# 版权声明

https://www.cnblogs.com/dechinphy/p/progress-bar.html