Python: Logging TypeError: not all arguments converted during string formatting

后端 未结 4 1219
独厮守ぢ
独厮守ぢ 2020-12-14 14:55

Here is what I am doing

>>> import logging
>>> logging.getLogger().setLevel(logging.INFO)
>>> from datetime import date
>>&g         


        
4条回答
  •  暖寄归人
    2020-12-14 15:20

    You could do the formatting yourself:

    logging.info('date={}'.format(date))
    

    As was pointed out by Martijn Pieters, this will always run the string formatting, while using the logging module would cause the formatting to only be performed if the message is actually logged.

提交回复
热议问题