python - 通过命令行仅针对特定模块禁用 python 警告

标签 python

当启动我的 Python 脚本时,我收到此警告:

/usr/lib/python2.7/dist-packages/cffi/model.py:526: UserWarning: 'point_conversion_form_t' has no values explicitly defined; next version will refuse to guess which integer type it is meant to be (unsigned/signed, int/long)
  % self._get_c_name())

我知道我可以像这样忽略这个警告:

PYTHONWARNINGS="ignore::UserWarning" python $MYSCRIPT

但这也将忽略我仍然希望看到的所有其他模块的 UserWarnings。 是否可以以更细粒度的方式指定忽略,例如传递应抑制警告的模块名称?

最佳答案

这将仅通过命令行忽略模块 cffi.model 的 UserWarnings:

PYTHONWARNINGS="ignore::UserWarning:cffi.model" python $MYSCRIPT

关于python - 通过命令行仅针对特定模块禁用 python 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37158090/

相关文章:

python - Ubuntu 上的 ClustalW

Python 缩进不直观

Python 脚本无法正确重新启动

python - Theano/numpy 高级索引

python - 如何将numpy数组转换为Matlab矩阵?

python - TKinter - 使用网格布局的框架中的小部件不是 'sticking'

python - 在 Python 中扁平化/反规范化 Dict/Json

python - 在 Python 中使用列表方法与使用字符串方法

多处理中共享dict()中的python共享Queue()

python - 我是否正确解析了这个 HTTP POST 请求?