美文网首页
2019-07-31Python从json数组取具体值

2019-07-31Python从json数组取具体值

作者: 黑猫不睡1920 | 来源:发表于2019-07-31 23:18 被阅读0次
import json

aa=[{
 "_id": "5436e3abbae478396759f0cf",
 "name": "ISIC_0000000",
 "updated": "2015-02-23T02:48:17.495000+00:00"
},
{
 "_id": "5436e3acbae478396759f0d1",
 "name": "ISIC_0000001",
 "updated": "2015-02-23T02:48:27.455000+00:00"
},
{

 "_id": "5436e3acbae478396759f0d3",
 "name": "ISIC_0000002",
 "updated": "2015-02-23T02:48:37.249000+00:00"
},
{
 "_id": "5436e3acbae478396759f0d5",
 "name": "ISIC_0000003",
 "updated": "2015-02-23T02:48:46.021000+00:00"
 }]

ss=json.dumps(aa,indent=4,ensure_ascii=False)
data = json.loads(ss)
for element in data:
    id = element["name"]
    print(id)

for each in data:
    print (each['_id'])
    print (each['name'])
    print (each['updated'])

运行结果
nelra.png

相关文章

网友评论

      本文标题:2019-07-31Python从json数组取具体值

      本文链接:https://www.haomeiwen.com/subject/pxxfdctx.html