from tqdm import tqdm
import time
def ones(epoch, end):
count = 100
bar = tqdm(total=count, leave=(epoch == end), desc="train", position=1)
for _ in range(count):
time.sleep(0.01)
bar.set_postfix({
"index": index, "epoch": epoch, "number": index ** 5 / 50000})
bar.update()
bar.close()
def main(start=0, end=100):
bar = tqdm(range(start, end), dynamic_ncols=True, leave=True, desc="Epochs")
for epoch in range(start, end):
ones(epoch + 1, end)
bar.update()
if __name__ == '__main__':
main(0, 100)
在终端显示效果
如果是在pycharm中运行,会出现金字塔的效果,在终端中不会,只会显示两行(上图所示),是很方便的,也可以打印