谁能帮我解释下这段python源码中logging的作用是什么?,pythonlogging,实际现象一段不熟悉的lo
谁能帮我解释下这段python源码中logging的作用是什么?,pythonlogging,实际现象一段不熟悉的lo
实际现象
一段不熟悉的logging用法( 猜测是给库打log 用的 )
预期现象
弄清楚该段 logging 代码的作用原理( 虽然有句注释 # Set default logging handler to avoid "No handler found" warnings. )
相关代码
requests.__init__.py中的用法
# Set default logging handler to avoid "No handler found" warnings.import loggingtry: # Python 2.7+ from logging import NullHandlerexcept ImportError: class NullHandler(logging.Handler): def emit(self, record): passlogging.getLogger(__name__).addHandler(NullHandler())
上下文环境
产品版本: requests最新
操作系统: Linux
Python: 2.7.x
意思就是你当前版本的logging模块没有NullHandler的时候就自己写一个,总之保证后续的代码有NullHandler可用
编橙之家文章,
相关内容
- Python大级别数运算问题,python级别运算,用hashlib.sha
- 求实现Python脚本判断中文字符是否为同一姓名思路方法
- Python SQLAlchemy定义触发器、存储过程是怎样实现的,p
- 没有编程基础能学好python语言吗,编程基础python,没有任
- flask调试不开httpserver提供静态文件应该怎么操作,fla
- 请问一个窗口内可以运行python多个线程吗?,一个窗口
- Python方法将前端获取二进制上传到upyun方法,求大神赐教
- Python attrs作用是什么?,pythonattrs作用是,from rest_fr
- python http请求用ihttplib\httplib2\urllib2谁速度最快,ihttpl
- 反向代理用Python怎么写?,反向代理Python,用python写一个
评论关闭