如何使 Prophet 的输出静音?

时间:2021-04-08 12:01:59

标签: python output facebook-prophet

我正在使用 Prophet(Facebook 的时间序列库),它产生了大量输出。像这样的东西: Prophet output

我已经沉默了一些像这样的输出:

@contextmanager
def suppress_stdout():
    with open(os.devnull, "w") as devnull:
        old_stdout = sys.stdout
        sys.stdout = devnull
        try:  
            yield
        finally:
            sys.stdout = old_stdout

但它不会让所有类型的输出静音,我如何让所有类型静音?

1 个答案:

答案 0 :(得分:1)

我怀疑您正在使用类似 IPython 的环境,例如Jupyter 笔记本。然后您可以在单元格中使用 %%capture magic command

例如

%%capture
output = do_some_verbose_things(args)

默认情况下,它还会捕获 stderr,我认为您看到的输出会出现在那里。

相关问题