Python的日志记录模块错过了"captureWarnings"功能

Bor*_*lik 4 python logging warnings

Python的标准日志记录模块应该包含一个有用的captureWarnings函数,它允许日志记录和警告模块之间的集成.但是,似乎我的安装错过了这个功能:

Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging
>>> logging.captureWarnings
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'captureWarnings'
>>> import logging.captureWarnings
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named captureWarnings
>>> import warnings
>>> import logging.captureWarnings
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named captureWarnings
>>>
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

Pet*_*rin 8

不幸的是,Python 2.6.5的日志记录模块中没有这样的方法.你需要Python 2.7.