1. ignore all warnings
.
import warnings
# Ignore all warnings
warnings.filterwarnings("ignore")
..
import warnings
# Ignore DeprecationWarning
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
# Code that produces DeprecationWarning
3. You can also use a decorator to ignore specific types of warnings:
.
import warnings
# Ignore DeprecationWarning with a decorator
@warnings.catch_warnings()
@warnings.filterwarnings("ignore", category=DeprecationWarning)
def my_function():
# Code that produces DeprecationWarning
..
Thank you.
๐๐ป♂️
www.marearts.com
No comments:
Post a Comment