python-3.x 如何忽略Tqdm实验警告?

ffscu2ro  于 2022-12-30  发布在  Python
关注(0)|答案(1)|浏览(244)

每次创建tqdm_gui对象时,都会打印一个警告。我试图用contextlib抑制它,但无济于事。

import contextlib as ctx
from tqdm import TqdmExperimentalWarning
from tqdm.gui import tqdm_gui

total = 0

with ctx.suppress(TqdmExperimentalWarning):
    for i in tqdm_gui(range(100_000_000)):
        total += i

print(total)

输出:

main.py:8: TqdmExperimentalWarning: GUI is experimental/alpha
  for i in tqdm_gui(range(100_000_000))

我如何消除警告?

w9apscun

w9apscun1#

尝试禁用参数

import contextlib as ctx
from tqdm import TqdmExperimentalWarning
from tqdm.gui import tqdm_gui

total = 0

with ctx.suppress(TqdmExperimentalWarning):
    for i in tqdm_gui(range(100_000_000), disable=True):
        total += i

print(total)

输出# No warning

相关问题