我有一个字符串看起来像这样,
我想把这些数据加载到类似于这样的字典中,
b'2018-02-27 11:42:40:b\'{"EventID":"65605751","Priority":"Lav Emerg","PriorityColor":"16725041","SortLevel":"7","VStationID":"1002","accepted_flag":"0","ack":"0","bedid":"42","elapseTimeInSeconds":"9","eventTimedOut":"0","failedname":" ","iconindex":"7","location":"1021","operating_mode":"0","pfunction_id":"8","priority_hw_id":"7","priorityindex":"2"}\''
我想把这些数据加载到类似于这样的字典中,
{"EventID":"65605751","Priority":"Lav Emerg","PriorityColor":"16725041","SortLevel":"7","VStationID":"1002","accepted_flag":"0","ack":"0","bedid":"42","elapseTimeInSeconds":"9","eventTimedOut":"0","failedname":" ","iconindex":"7","location":"1021","operating_mode":"0","pfunction_id":"8","priority_hw_id":"7","priorityindex":"2"}
请问有人可以告诉我如何在Win7 Python 3.4上完成这个任务吗?请注意字符串长度可能是可变的。但日期,时间,“{”和“}”在开头和结尾肯定会出现。
{...}
序列,并使用json库将其解析为字典。 - Laur Ivan