一个列表当中有一个日期的值,我想求这个日期里面当天最大时间的那一条,大神们如何写呢?
原始列表
`
[{
"count": 0,
"create_time": "2017-03-22 22:00:00",
"level": "1"
},
{
"count": 5,
"create_time": "2017-03-22 22:00:00",
"level": "0"
},
{
"count": 5,
"create_time": "2017-03-22 22:00:00",
"level": "2"
},
{
"count": 5,
"create_time": "2017-03-22 23:00:00",
"level": "0"
},
{
"count": 0,
"create_time": "2017-03-22 23:00:00",
"level": "1"
},
{
"count": 5,
"create_time": "2017-03-22 23:00:00",
"level": "2"
}]`
想要输出的列表
[{
"count": 5,
"create_time": "2017-03-22 23:00:00",
"level": "0"
},
{
"count": 0,
"create_time": "2017-03-22 23:00:00",
"level": "1"
},
{
"count": 5,
"create_time": "2017-03-22 23:00:00",
"level": "2"
}]
Change sum to max in the last question:
Problems like this can be solved using groupby
The idea is to sort first and then filter