【发布时间】:2017-07-12 17:57:06
【问题描述】:
我有一个包含任意行数和 json 字符串的日志文件。我只需要从日志文件中提取一个 json 数据,但仅在“_____GP D____”之后。我不想要文件中的任何其他行或 json 数据。
这就是我的输入文件的样子
INFO:modules.gp.helpers.parameter_getter:_____GP D_____
{'from_time': '2017-07-12 19:57', 'to_time': '2017-07-12 20:57', 'consig_number': 'dup1', 'text': 'r155', 'mobile': None, 'email': None}
ERROR:modules.common.actionexception:ActionError: [{'other': 'your request already crossed threshold time'}]
{'from_time': '2016-07-12 16:57', 'to_time': '2016-07-12 22:57', 'consig_number': 'dup2', 'text': 'r15', 'mobile': None, 'email': None}
如何仅在 '_____GP D____' 之后找到 json 字符串?
【问题讨论】:
标签: json regex python-3.x parsing logging