我正在尝试在自己的脚本中添加日志,并遵循了Python 日志教程。
example code
import logging logging.basicConfig(filename='example.log',level=logging.DEBUG) logging.debug('This message should go to the log file') logging.info('So should this') logging.warning('And this, too')
但我在脚本所在目录中找不到 example.log
文件。当我调用 os.getcwd()
时,它返回 C:\\users\\eda
,也没有日志文件。
basicConfig
;如果之前已经调用过(比如在 REPL 中玩耍时),那么新的调用基本上没有任何效果。 - tripleee