【发布时间】:2020-09-27 12:47:08
【问题描述】:
我在 ubuntu 20.04 上使用 python 3.8,我无法让 DEBUG 语句记录到我的其他文件,我的代码 -
import logging
logging.basicConfig(level=logging.DEBUG, filename = 'logDEBUG.txt')
def say(x):
print(x)
phrase = 'hi'
logging.debug(say(phrase))
【问题讨论】:
-
你的函数没有返回任何东西。
-
print写入标准输出而不是文件。您只需返回:return x
标签: python python-3.x debugging logging