찾다

 >  Q&A  >  본문

Python-requests中, 这一段logging的用法是什么作用 ?

实际现象

预期现象

相关代码

# Set default logging handler to avoid "No handler found" warnings.
import logging
try:  # Python 2.7+
    from logging import NullHandler
except ImportError:
    class NullHandler(logging.Handler):
        def emit(self, record):
            pass

logging.getLogger(__name__).addHandler(NullHandler())

上下文环境

天蓬老师天蓬老师2872일 전587

모든 응답(1)나는 대답할 것이다

  • ringa_lee

    ringa_lee2017-04-18 10:25:03

    즉, 현재 버전의 로깅 모듈에 NullHandler가 없으면 직접 작성하고 후속 코드에 NullHandler를 사용할 수 있는지 확인하세요.

    회신하다
    0
  • 취소회신하다