冒泡泡de可乐
代码都是思想和概念的体现~每多学一点知识,就能少写一行代码~
dic =   {
        "error_code": 0,
        "stu_info": [
                {
                        "id": 2057,
                        "name": "xiaohei",
                        "sex": "nan",
                        "age": 29,
                        "addr": "beijing",
                        "grade": "tianxie",
                        "phone": "18712321234",
                        "gold": 100
                }
        ]
}
import jsonpath
s = jsonpath.jsonpath(dic,'$..name')   #不管有多少层,写两个.都能取到
print(s) #['xiaohei'] 返回的是一个列表
s = jsonpath.jsonpath(dic,'$..hehe')   #当不存在hehe这个key时,返回false
print(s)  #False

 

posted on 2018-11-27 09:38  HathawayLee  阅读(8572)  评论(0编辑  收藏  举报