如何禁用 Python 警告? [英] How to disable Python warnings?

查看:91
本文介绍了如何禁用 Python 警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理使用 警告 库.阅读(/扫描)文档我只找到了一种方法禁用警告对于单一功能.但我不想更改太多代码.

I am working with code that throws a lot of (for me at the moment) useless warnings using the warnings library. Reading (/scanning) the documentation I only found a way to disable warnings for single functions. But I don't want to change so much of the code.

有没有像 python -no-warning foo.py 这样的标志?

Is there a flag like python -no-warning foo.py?

你会推荐什么?

推荐答案

-W 选项.

python -W ignore foo.py

这篇关于如何禁用 Python 警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆