移除 requests 中的 logging debug信息
使用 requests
模块时,为了方便调试会搭配logging
,但是requests里面也会输出debug等级的信息这就会让我们窗口变得杂乱,如下。
2023-10-06 15:20:24,912 DEBUG: Starting new HTTPS connection (1): www.xxx.com:443
2023-10-06 15:20:25,390 DEBUG: https://www.xxx.com:443 "GET /x/xxxxxx HTTP/1.1" 200 None
我们可以在引入logging
模块后再前面将requests
的日志等级改一下,如下。
import logging
# 将requests的改为error
logging.getLogger('urllib3.connectionpool').setLevel(logging.ERROR)
# 我们用debug
logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=logging.DEBUG)
以上就是解决方案