有没有办法防止在 pdf 或 html 文件中打印警告?

Is there a way to prevent warnings from printing in pdf or html file?

我正在使用 JupyterLab,在处理平方根或复数值时,python 给出 RuntimeWarningComplexWarning。在将文件保存为 pdf 或 html?

时,有没有办法防止这些警告出现

在您的脚本顶部:

import warnings
warnings.filterwarnings("ignore")

Temporarily Suppressing Warnings