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

时间:2011-10-02 14:50:44

标签: python logging warnings

Python的标准日志记录模块是supposed to contain a useful captureWarnings function,它允许日志记录和warnings模块之间的集成。但是,似乎我的安装错过了这个功能:

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
>>>

我做错了什么?

1 个答案:

答案 0 :(得分:8)

不幸的是,Python 2.6.5's logging module中没有这样的方法。你需要Python 2.7。