tqdm
from tqdm import tqdm
import time
for i in tqdm(range(1000)):
time.sleep(0.01)
效果如下:
37%|█████████ | 370/1000 [00:03<00:06, 98.89it/s]
只要是可迭代的对象,均可使用使用tqdm
progressbar
import time
from tqdm import tqdm
from progressbar import *
for i in tqdm(range(100)):
time.sleep(0.02)
widgets=['Epoch i ',Percentage(),' ',Bar(),' ',ETA()]
pb = ProgressBar(widgets=widgets)
for i in pb(range(500)):
time.sleep(0.02)
输出:
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:02<00:00, 49.60it/s]
Epoch i 100% |####################################################################################################################################################| Time: 0:00:10
其中widgets
是一个数组,可以任意组合文字和函数,Percentage()是百分比,Bar()是进度条,ETA()是剩余时间。
网友评论