tqdm,带有单独线路上的记录器



我查看了更改日志记录"打印";函数为";tqdm.write";所以日志记录不会;我不会干扰进度条和Python进度条THROUGH日志记录模块,它们没有我想要的。

我希望在不同的行上有日志消息和tqdm进度条。

我试着从https://stackoverflow.com/a/38739634/10732321这给了我以下输出:

50%|█████     | 50/100 [00:05<00:05,  9.65it/s]Half-way there!
100%|██████████| 100/100 [00:10<00:00,  9.71it/s]

当然进度条和日志消息是互斥的,但我想要下一行的Half-way there!,即

50%|█████     | 50/100 [00:05<00:05,  9.65it/s]
Half-way there!
100%|██████████| 100/100 [00:10<00:00,  9.71it/s]

怎么办?谢谢

实际上我更喜欢避免tqdm,而只是这样做。你可以添加你自己的口味和变化。

import time

n = 25
for i in range(n):
time.sleep(0.1)
progress = int(i / n * 50)
print(f'running {i+1} of {n} {progress*"."}', end='r', flush=True)
if i == int(n/2):
print('n >>> half way there')
if i+1 == n:
print('nfinished process !!')

输出如下:

running 13 of 25 ........................
>>> half way there
running 25 of 25 ................................................
finished process !!

最新更新