在 python 中获取字节数组子字符串查找的最大值
In python get max value on lookup of byte array substring
我正在使用 python3。以下是我的示例数据
b'{"receivedTimestamp":1604484102747,"application":"MMT","messageType":"BusEvent","utcTimestamp":1604484102711,"data":[{"id":56476901531}]}{"receivedTimestamp":1604484102748,"application":"MMT","messageType":"BusEvent","utcTimestamp":1604484102711,"data":[{"id":56476901532}]}'
在python中,我猜上面的数据被视为字节数组
数据说明
如果我们观察到有 2 json 条消息,每个 json 条消息标签都以 receivedTimestamp
开头
我需要什么?
我需要找到这两条消息的最大时间戳,它应该 return 我的值为 1604484102748,因为它更大。
我正在努力解析这条消息。请求任何人解析此数据或为我指明正确的方向以构建代码并在 python.
中获得预期值
提前致谢
tmp = str(my_json)
i = tmp.rfind('receivedTimestamp') # index of last appearance receivedTimestamp
i = i-2 #index between jsons
first_json = json.loads(tmp[2:i])
second_json = json.loads(tmp[i:-1])
我正在使用 python3。以下是我的示例数据
b'{"receivedTimestamp":1604484102747,"application":"MMT","messageType":"BusEvent","utcTimestamp":1604484102711,"data":[{"id":56476901531}]}{"receivedTimestamp":1604484102748,"application":"MMT","messageType":"BusEvent","utcTimestamp":1604484102711,"data":[{"id":56476901532}]}'
在python中,我猜上面的数据被视为字节数组
数据说明 如果我们观察到有 2 json 条消息,每个 json 条消息标签都以 receivedTimestamp
开头我需要什么? 我需要找到这两条消息的最大时间戳,它应该 return 我的值为 1604484102748,因为它更大。
我正在努力解析这条消息。请求任何人解析此数据或为我指明正确的方向以构建代码并在 python.
中获得预期值提前致谢
tmp = str(my_json)
i = tmp.rfind('receivedTimestamp') # index of last appearance receivedTimestamp
i = i-2 #index between jsons
first_json = json.loads(tmp[2:i])
second_json = json.loads(tmp[i:-1])