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

Python 有没有办法防止以pdf或html文件打印警告?,python,jupyter-lab,Python,Jupyter Lab,我正在使用JupyterLab,在使用平方根或复数值时,python会给出RuntimeWarning或ComplexWarning。在将文件保存为pdf或html时,是否有方法防止出现这些警告?在脚本顶部: import warnings warnings.filterwarnings("ignore") python-W忽略foo.py?

我正在使用JupyterLab,在使用平方根或复数值时,python会给出
RuntimeWarning
ComplexWarning
。在将文件保存为pdf或html时,是否有方法防止出现这些警告?

在脚本顶部:

import warnings
warnings.filterwarnings("ignore")

python-W忽略foo.py