python development often encountered in the case of error reporting, but warning usually does not affect the operation of the program, and sometimes especially annoying, here we say how to ignore the warning error.
Before we talk about ignoring warnings, let's talk about how to actively generate warning errors, here we use the warnings module, see the following code:
import warnings def fxn(): ("deprecated", DeprecationWarning) with warnings.catch_warnings(): ("ignore") fxn()
This generates a warning error
So how do you control the output of warning errors? It's simple.
import warnings ("ignore")
This ignores the warning error output. It's simple, isn't it~~
Again, one has to ask how to ignore the output of warning errors at the command line. It is also very simple:
python -W ignore
That's good.
Content Extension:
1) Warnings in the code
import warnings ("ignore")
2) Ignore the output of warning errors at the command line:
python -W ignore
The above is this introduction to all the relevant knowledge points, my editorial combined with several related content, I hope to be able to help you.