我有一个以下格式的json,我只想保存其中的两部分。但我把它当作单独的角色。你能帮帮我吗
for data in results['results']:
dictionary = dict(zip("title:", data['title']))
dictionary = dict(zip("uuid:", data['uuid']))
Json
results": [
{
"title": "subject1",
"ja_pub_yyyy": 1395,
"uuid": "86ae6",
"external_link": null,
"fulltext_status": 1,
},
{
"title": "subject2",
"ja_pub_yyyy": 1395,
"uuid": "86ae6",
"external_link": null,
"fulltext_status": 1,
}
]
新结果
results": [
{
"title": "subject1",
"id": "86ae6",
},
{
"title": "subject2",
"id": "86ae6",
}]
你也可以这样做
您没有正确地创建每个
dict
。更简单的是:我已经演示了如何收集每个
dictionary
尝试循环json并将对象属性提取到新数组中。 例如:
相关问题 更多 >
编程相关推荐