我是python的新手,我试图根据一些条件将一个字典列表分割成不同的字典列表。
This is how my list looks like this:
[{'username': 'AnastasiadesCY',
'created_at': '2020-12-02 18:58:16',
'id': 1.33421029132062e+18,
'language': 'en',
'contenttype': 'text/plain',
'content': 'Pleased to participate to the international conference in support of the Lebanese people. Cypriot citizens, together with the Government 🇨🇾, have provided significant quantities of material assistance, from the day of the explosion until today.\n\n#Lebanon 🇱🇧'},
{'username': 'AnastasiadesCY',
'created_at': '2020-11-19 18:13:06',
'id': 1.32948788307022e+18,
'language': 'en',
'contenttype': 'text/plain',
'content': '#Cyprus stand ready to support all efforts towards a coordinated approach of vaccination strategies across Europe, that will prove instrumental in our fight against the pandemic.\n\nUnited Against #COVID19 \n\n#EUCO'},...
我想把所有列表中具有相同用户名的元素分割成独立的字典列表并进行分组。列表中的元素--所以每个字典--是按用户名排序的。
有没有一种方法可以在字典上循环,并将每个元素追加到一个列表中,直到 "项目1 "中的用户名等于 "项目1+1 "中的用户名,如此循环?
谢谢你的帮助!