【发布时间】:2015-09-19 02:17:42
【问题描述】:
在过去的一个小时里,我一直被困在这个问题上。我已将登录插入到我的 tkinter gui,但无法使其正常工作。然后我开始删除部分,直到我在非常 python 文档中得到了最简单的例子,它不会工作。在这一点上,我没有其他要删除的内容。
代码如下:
import logging
LOG_FILENAME = r'logging_example.out'
logging.basicConfig(filename=LOG_FILENAME ,level=logging.DEBUG)
logging.debug('This message should go to the log file')
logging.info('So should this')
logging.warning('And this, too')
f = open(LOG_FILENAME, 'rt')
try:
body = f.read()
finally:
f.close()
print('FILE:')
print (body)
警告会打印到标准输出,但不会生成文件。 我在 Windows 7 上运行 python 3.4、x64。它是 anacondas 发行版,所以它在 spyder 内的 Ipython 中运行。
我想这应该可以工作
【问题讨论】:
-
这在从 shell 运行 python.exe 时有效。必须与您的环境有关。