Bootstrap

python项目报错

— Logging error —
Traceback (most recent call last):
File “d:\Users\xd\miniconda3\envs\py38_base\lib\logging_init_.py”, line 1085, in emit
msg = self.format(record)
File “d:\Users\xd\miniconda3\envs\py38_base\lib\logging_init_.py”, line 929, in format
return fmt.format(record)
File “d:\Users\xd\miniconda3\envs\py38_base\lib\logging_init_.py”, line 668, in format
record.message = record.getMessage()
File “d:\Users\xd\miniconda3\envs\py38_base\lib\logging_init_.py”, line 373, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting

原因,在调用logger.info()方法时,直接將非str类型的变量放入其中

解决:
直接將需要打印的变量强制转为str类型

str_a = str(a)
logger.info(str_a)

;