我只想用Python从JSON中提取特定的位置。我对“data”中的所有条目都感兴趣(见下面的代码)。我感兴趣的条目是“4101”和“3591”。我对更深层次的细节不感兴趣。如何获得条目列表。我的最终结果应该是output=[“4101”,“3591”,等等..]
我正在使用json.dump文件Python。 有什么我可以添加的属性吗json.dump文件(记录)?就像json.dump文件(记录,findonly=“data”,depth=“1”)?你知道吗
records = """{
"status": "ok",
"count": 130,
"data": {
"4101": {
"is_gift": false,
"nation_i18n": "Japan",
"name": "type-91",
"level": 1,
"nation": "japan",
"is_premium": false,
"plane_id": 4101,
"images": {
"small": "http://worldofwarplanes.eu/static/1.1.0/encyclopedia/planopedia/vehicle/small/type-91.png",
"large": "http://worldofwarplanes.eu/static/1.1.0/encyclopedia/planopedia/vehicle/large/type-91.png",
"medium": "http://worldofwarplanes.eu/static/1.1.0/encyclopedia/planopedia/vehicle/medium/type-91.png"
},
"name_i18n": "Nakajima Type-91",
"type": "fighter"
},
"3591": {......[it goes on and on]
因为我搜索的所有条目都是4位数字,所以我选择了regexp:
使用^{} 将JSON解析为Python数据结构,然后访问所需的任何内容:
输出:
相关问题 更多 >
编程相关推荐