Python 的日志记录模块缺少 "captureWarnings"函数

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

我做错了什么?

最佳答案

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

关于Python 的日志记录模块缺少 "captureWarnings"函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7627075/

相关文章:

python - 将图像转换为 Python 中的二维坐标数组以实现两点相关

python - logger.removeHandler(logger.handlers[0]) 如何抛出 ValueError : list. 删除(x) : x not in list?

java - Log4j2 配置日志到文件

Perl 警告退出

Nhibernate 探查器显示警告 "Use explicit Save or Update in session"

java - 如何停止关于目标文件夹内容的 Eclipse 警告?

python - 在 Python 和 matplotlib 中的 3D 散点图中的两点之间绘制矩形或条形

python - 使用 pySpark 迭代数据框的每一行

python - 如何检查 python 对象是否是 numpy ndarray

python - 登录具有多个入口点的 Python 项目