下面来说一下如何忽略这些警告。
python -W ignore yourscript.py
import warnings
def fxn():
warnings.warn("deprecated", DeprecationWarning)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
fxn()如果不想使用以上方法,可以直接在python源代码中的开始添加如下代码:
import warnings
warnings.filterwarnings("ignore")这样就可以忽略python报警告性错误啦
Copyright © 2019- truthgptcn.cn 版权所有
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务