我有以下代码,从Python手动复制:“模块”对象有没有属性“basicConfig”
import logging
LOG_FILENAME = 'example.log'
logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG)
logging.debug('This message should go to the log file')
当我尝试运行脚本(通过python.exe script.py
)我得到的'module' object has no attribute 'basicConfig'
错误。
然而,当我复制和粘贴在交互模式下的代码(通过python.exe然后复制并粘贴实际的代码),我没有得到任何错误。代码运行良好。
我有python 2.6.6。
谢谢!
更具体地说,很多人使用一个名为X.py的文件来测试模块X :) – delnan 2010-12-19 10:58:36
就是这样。非常感谢你! – Alex 2010-12-19 11:11:05
5年后;)。有一个** logging.pyc **留下了很多麻烦 – drtf 2015-11-15 12:41:12