这里是嵌套tqdm进度条的示例。
import time
import tqdm
for i in tqdm.tqdm(range(3)):
for j in tqdm.tqdm(range(5)):
print(i," : ", j)
我在Jupyter Notebook上尝试了它,但没有显示任何错误! 但是,在iPython控制台上可以正常工作!
这里是嵌套tqdm进度条的示例。
import time
import tqdm
for i in tqdm.tqdm(range(3)):
for j in tqdm.tqdm(range(5)):
print(i," : ", j)
我在Jupyter Notebook上尝试了它,但没有显示任何错误! 但是,在iPython控制台上可以正常工作!
我刚刚找到了要使用的解决方案。这个解决方案有很多例子在这里。
我修改了原帖中的示例,包括解决方案和时间延迟以便可视化(最终输出相同,无论是否使用延迟)。
from time import sleep
from tqdm import tqdm_notebook
for i in tqdm_notebook(range(3)):
for j in tqdm_notebook(range(5)):
sleep(0.1)
print(i," : ", j)
print("Done!")
最终的输出看起来是这样的。在处理过程中,它非常流畅(没有跳动或其他疯狂的东西)。
from time import sleep
from tqdm import tqdm_notebook as tqdm
for i in tqdm(range(3)):
for j in tqdm(range(5)):
sleep(0.1)
print(i," : ", j)
print("Done!")
from tqdm.notebook import tqdm
。 - Tomasz Gandorfrom tqdm.auto import tqdm
- Will
from tqdm.notebook import tqdm
。 - Tomasz Gandor