我有以下代码,从Python手册复制:
import logging
LOG_FILENAME = 'example.log'
logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG)
logging.debug('This message should go to the log file')
Run Code Online (Sandbox Code Playgroud)
当我尝试运行脚本(通过python.exe script.py
)时,我得到一个错误'module' object has no attribute 'basicConfig'
.
但是,当我以交互模式复制并粘贴代码时(通过python.exe然后复制并粘贴实际代码),我没有得到任何错误.代码运行正常.
我有python 2.6.6.
谢谢!
python ×2