import jsonpath d = {'car':[ {'cc':'dd'}, {'car':[ { 'bwn':111 }, {'lq':222} ]} ]} def get_value(data,key): # 无论多少层,..key都可以取到,如果key有重复,则返回取到的所有数据 result = jsonpath.jsonpath(data,'$..%s'%key) return result res = get_value(d,'$..lq')#无论多少层,..key都可以取到,如果key有重复,则返回取到的所有数据 print(res)
当key不存在时,返回False
python学习笔记(二十)-- jsonpath
猜你喜欢
转载自www.cnblogs.com/yanyan-/p/10933617.html
今日推荐
周排行