【问题标题】:Python's logging module misses "captureWarnings" functionPython 的日志记录模块缺少“captureWarnings”功能
【发布时间】:2011-10-02 14:50:44
【问题描述】:

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


    【解决方案1】:

    很遗憾,Python 2.6.5's logging module 中没有这种方法。你需要 Python 2.7。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-06-04
    • 2011-11-29
    • 2021-11-23
    • 1970-01-01
    • 1970-01-01
    • 2020-08-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多