用logging.info()替换print('',end ='\ r')语句会引发错误

问题描述 投票:-2回答:1

有没有一种方法可以将带有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 logging printing flags
1个回答
0
投票

如果使用的是Python> = 3.2,则可以在terminator上设置StreamHandler属性以确定终止符是什么。当然,它默认为\n。参见the documentation

© www.soinside.com 2019 - 2024. All rights reserved.