我有一个以下格式的 json,我只想保存它的 2 部分。但我把它作为单独的字符。你能帮我么?
for data in results['results']:
dictionary = dict(zip("title:", data['title']))
dictionary = dict(zip("uuid:", data['uuid']))
杰森
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
正确地创造每一个。更简单:
new_result = []
for data in results['results']:
l = ((k,data[k]) for k in ("title","uuid"))
dictionary = dict(l)
new_result.append(dictionary)
我已经演示了收集每个dictionary
.
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句