파이썬 함수 & 라이브러리 - warnings 모듈

반응형

파이썬으로 작성된 응용 프로그램 개발자는 기본적으로 사용자에게 모든 파이썬 수준 경고를 숨기고, 테스트를 실행하거나 달리 응용 프로그램에 대해 작업할 때만 표시하고 싶을 수 있습니다.

파이썬 수준의 경고를 숨길 때는 아래의 코드를 작성합니다.

 

warnings.filterwarnings()

  • 경고 메시지를 무시하고 싶을 때: ‘ignore
import warnings
warnings.filterwarnings('ignore')
  • 경고 메세지를 다시 활성화 시킬 때: ‘default
import warnings
warnings.filterwarnings(action='default')

 

 

 

 

# https://docs.python.org/ko/3/library/warnings.html

반응형