问题描述
我想禁用来自特定模块的所有警告,以便
import foo
import bar
foo.warning_method() # should not warn
bar.warning_method() # should warn
有没有办法控制这个,还是我需要为所有特定的警告类型设置过滤器?
解决方法
找到解决方案:module
参数:
warnings.filterwarnings('ignore',module='foo')
我想禁用来自特定模块的所有警告,以便
import foo
import bar
foo.warning_method() # should not warn
bar.warning_method() # should warn
有没有办法控制这个,还是我需要为所有特定的警告类型设置过滤器?
找到解决方案:module
参数:
warnings.filterwarnings('ignore',module='foo')