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
>>>
我究竟做错了什么?
解决方法:
不幸的是,Python 2.6.5’s logging module中没有这样的方法.你需要Python 2.7.