jupyter笔记本同一行的进度条更新

use*_*212 5 python jupyter-notebook tqdm

我喜欢tqdm 进度条,因为它很简单。但我注意到,在某些情况下,进度条的每次更新都会打印在 jupyter 笔记本的新行中,如以下屏幕截图所示:

换行符中的 tqdm 进度更新

如何确保 tqdm 进度条的更新打印在 jupyter 笔记本的同一行中,如以下屏幕截图所示:

在此输入图像描述

cal*_*ini 3

tqdm有一个用于处理 jupyter Notebook 中的输出的特定模块tqdm_notebook

import time
from tqdm import tqdm_notebook as tqdm

for i in tqdm(range(10)):
   time.sleep(1)
Run Code Online (Sandbox Code Playgroud)