1.jsonpath模块
import jsonpath wsc = { "money":19000, "house":{ "beijing":["三环","四环","五环"], "shanghai":["静安区","浦东新区"] }, "car":["bmw",‘benz‘,‘audi‘,‘byd‘], "pets":[ {"name":"xiaohei","type":"dog"}, {"name":"xiaobai","type":"cat"}, {"name":"xiaofen","type":"cat"}, {"name":"xiaolan","type":"dog"}, ] } #$.pets[0].type #result = wsc["pets"][0]["type"] #原有的方法获取 #result = jsonpath.jsonpath(wsc,"$.pets[0].type") #result = jsonpath.jsonpath(wsc,"$..car") result = jsonpath.jsonpath(wsc,"$..beijing") print(result)