Joh*_*hnM 5 python progress-bar tqdm
我在 Jupiter 笔记本中使用 tqdm。通常我会在白色背景上看到一个绿色进度条。但是,现在我看到粉红色背景上有一个黑色进度条:
import tqdm, tqdm.notebook
from time import sleep
# first progress bar
for i in tqdm.notebook.tqdm(range(10)):
sleep(.1)
# second progress bar
for i in tqdm.notebook.tqdm(range(10)):
sleep(.1)
# third progress bar
for i in tqdm.tqdm(range(10)):
sleep(.1)
# fourth progress bar
for i in tqdm.tqdm(range(10), colour='green'):
sleep(.1)
Run Code Online (Sandbox Code Playgroud)
产生这四个条:
我想要的是一个绿色的进度条,没有粉红色的背景。
我安装 PyQt5 后出现了这种行为变化。我已经卸载了,但行为仍然存在。
另外,以前我tqdm.notebook.tqdm在笔记本中使用过进度条。现在该函数不显示进度条(条 1 和条 2)。我需要使用tqdm.tqdm(第 3 条和第 4 条)。
我认为问题与后端有关。
粉红色背景意味着输出转到sys.stderr. 要获得白色背景,请使用 tqdm 参数file。要更改颜色使用参数colour:
for i in tqdm(range(50), file=sys.stdout, colour='GREEN'):
请参阅tqdm 文档中的更多信息
| 归档时间: |
|
| 查看次数: |
3108 次 |
| 最近记录: |