用 logging.info() 替换 print('', end='\r') 语句会抛出错误
Replacing print('', end='\r') statements with logging.info() throws error
有没有办法将带有 end='\r' 标志的格式化字符串传递给记录器?
以前我曾经有一个 print() 语句,我用 logging.info() 替换了它,但它现在停止工作了
import logging
logging.basicConfig(level=logging.DEBUG)
logging.info("Running operation ID: {0} on {1}. fl-queuetool -z {1} log {0}".format(str(oper_ID), zone))
while True:
stat = getOperationStatus(zone, oper_ID)
logging.info(stat, end='\r')
终端输出:
INFO:root:Running operation ID: 6057 on star. fl-queuetool -z star log 6057
DEBUG:root:_log() got an unexpected keyword argument 'end'
有办法解决吗?在文档中它读取函数接受 *args...
logging.info(msg, *args, **kwargs)¶
Logs a message with level INFO on the root logger. The arguments are interpreted as for debug().
如果您使用的是 Python >= 3.2,您可以在 StreamHandler
上设置 terminator
属性以确定终止符是什么。当然,它默认为 \n
。参见 the documentation。
有没有办法将带有 end='\r' 标志的格式化字符串传递给记录器? 以前我曾经有一个 print() 语句,我用 logging.info() 替换了它,但它现在停止工作了
import logging
logging.basicConfig(level=logging.DEBUG)
logging.info("Running operation ID: {0} on {1}. fl-queuetool -z {1} log {0}".format(str(oper_ID), zone))
while True:
stat = getOperationStatus(zone, oper_ID)
logging.info(stat, end='\r')
终端输出:
INFO:root:Running operation ID: 6057 on star. fl-queuetool -z star log 6057
DEBUG:root:_log() got an unexpected keyword argument 'end'
有办法解决吗?在文档中它读取函数接受 *args...
logging.info(msg, *args, **kwargs)¶
Logs a message with level INFO on the root logger. The arguments are interpreted as for debug().
如果您使用的是 Python >= 3.2,您可以在 StreamHandler
上设置 terminator
属性以确定终止符是什么。当然,它默认为 \n
。参见 the documentation。