While I am trying to retrieve values from JSON string, it gives me an error:
data = json.loads('{"lat":444, "lon":555}')
return data["lat"]
But, if I iterate over the data, it gives me the elements (lat
and lon
), but not the values:
data = json.loads('{"lat":444, "lon":555}')
ret = ''
for j in data:
ret = ret + ' ' + j
return ret
Which returns: lat lon
What do I need to do to get the values of lat
and lon
? (444
and 555
)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…