a = {“name”:“123”,“data”:{“result”:[{“src”:“python1”},{“src”:“python2”},{“src”:“python3”}]}} 找到 python1/python2/python3
# 一步步拆分
a ={"name":"123","data":{"result":[{"src":"python1"},{"src":"python2"},{"src":"python3"}]}}
b = a['data']# 先找key‘data’对应的值,赋予给b
c = b['result']# 先找key‘result’对应的值,赋予给c, c是个列表print('a = ',a)print('b = ',b)print('c = ',c)for d in c:# 对列表遍历print('d = ',d)print(d['src'])# 对每个字典找取key‘src’对应的值
a ={'name':'123','data':{'result':[{'src':'python1'},{'src':'python2'},{'src':'python3'}]}}
b ={'result':[{'src':'python1'},{'src':'python2'},{'src':'python3'}]}
c =[{'src':'python1'},{'src':'python2'},{'src':'python3'}]
d ={'src':'python1'}
python1
d ={'src':'python2'}
python2
d ={'src':'python3'}
python3
结果