Sad*_*daf 23 python visual-studio-code jupyter-notebook
我在 Visual Studio Code 中使用启用了暗模式的 Jupyter 笔记本。我使用 tqdm 可视化进度条,但它不会显示为黑色。看图片:

根据GitHub 上的这个问题,这不是 Jupyter、ipywidget 或 tqdm 本身的问题,它只与VSCode有关。
有什么解决方法可以解决这个问题吗?
小智 0
您可以使用使用 ANSI 转义码设置颜色的自定义格式将tqdm-bar_format参数传递给 tqdm。
像这样的东西:
from tqdm import tqdm
import time
# Custom format with ANSI escape codes for dark green color
dark_green = "\033[1;32;40m"
bar_format = f"{dark_green}{{l_bar}}{{bar:50}} [{{elapsed}}]{{r_bar}}"
# Create tqdm progress bar with custom format
for i in tqdm(range(100), bar_format=bar_format):
time.sleep(0.01)
Run Code Online (Sandbox Code Playgroud)
此外,这篇文章也会有所帮助。