登录python时出现TypeError

时间:2019-01-04 13:29:56

标签: python string logging typeerror

我有一个JSON输入,我正在尝试记录特定键的值。但这向我显示TypeError:在字符串格式化期间,并非所有参数都已转换。

msg = {'job_id' = '11', 'status' = 'complete', 'tr_no' = 'S$Wed'}

logger.info('Process Completed:')
logger.info(msg["tr_no"], 'Successful' )

我正在使用python 2.7。我也按照以下方式尝试过,但收到了相同的错误消息

logger.info(str(msg["tr_no"]), 'Successful' )

1 个答案:

答案 0 :(得分:-1)

import logging as logger
msg = dict(job_id='11', status='complete', tr_no='S$Wed')
logger.info('Process Completed:')
logger.info(msg["tr_no"], 'Successful' )

尝试此代码.....

或将第二行替换为:

msg = {'job_id':'11', 'status':'complete', 'tr_no':'S$Wed'}

谢谢。