Here I am giving some multiple examples to turn off warnings in Python.
Example 1: Python - Turn Off Warnings
If you have set your logging in Python to debug, you may experience the issue. Try the below code:
import nsepython import warnings import logging logging.basicConfig(level=logging.ERROR) warnings.filterwarnings("ignore") print(nse_quote_ltp("RELIANCE"))
Example 2:
In some cases, this works too:
import warnings warnings.filterwarnings("ignore")
Example 3:
You can use the catch_warnings()
function to suppress the warnings in Python:
import warnings def fxn(): warnings.warn("deprecated", DeprecationWarning) with warnings.catch_warnings(): warnings.simplefilter("ignore") fxn()