重新编辑,使其更加清晰和简单
对于以下数据
[
{
"name": "name1",
"a_id": "12345",
"b_id": "0d687c94c5f4"
},
{
"name": "name2",
"a_id": "67890",
"b_id": "0d687c94c5f4"
},
{
"name": "name3",
"a_id": "23857",
"b_id": "9ec34be3d535"
},
{
"name": "name4",
"a_id": "84596",
"b_id": "9ec34be3d535"
},
{
"name": "name5",
"a_id": "d82ebe9815cc",
"b_id": null
}
]
如何获得
基于“b_id”“0d687c94c5f4”:
id1 = 12345
id2 = 67890
基于“b_id”“9ec34be3d535”:
id3 = 23857
id4 = 84596
你的要求不太清楚。。但我想你的意思是你想用一个不同的键重新组合json列表。。。你可以用itertools来做
试试这个:
或者以字典的形式
相关问题 更多 >
编程相关推荐