欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

【jupyter】notebook屏蔽warning信息输出

程序员文章站 2022-05-25 16:13:34
...

使用warnings包来实现信息屏蔽:

import warnings
warnings.filterwarnings("ignore")
# caution: there is a 's' after warning !!--> 
# >>>>>>>>> warnings<<<<<<<<

# if pervious not working, try following:
# 1.
# warnings.filterwarnings('ignore')
# warnings.simplefilter('ignore')
# 2.
# warnings.simplefilter("ignore") 
# warnings.warn("deprecated", DeprecationWarning)
# 3. command line
# python -W ignore file.py

ref: warnings package, 1, 2. 3, 4