4
Python的標準日誌記錄模塊是supposed to contain a useful captureWarnings function,它允許在日誌記錄和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
>>>
我做錯了什麼?
python 2.6有什麼變通辦法嗎? –
@JeffTsui您可能會嘗試從https://hg.python.org/cpython/file/2.7/Lib/logging/__init__.py#l1701反向移植它(如果能夠正常工作,請提供新答案) –