1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| >>> r = {"spatialReference":{"wkid":4326},"candidates":[{"address":"Paris, ile de france75110 Paris, FRA","location":{"x":3.6858501,"y":47.9234886},"score":81,"attributes":{"MatchLevel":"city","Score":81,"North_Lat":"45.9328003","South_Lat":"45.9109001","West_Lon":"6.6802702","East_Lon":"6.73383"}}]}
>>> print type(r)
<type 'dict'>
>>> for e in r:
... print e
...
candidates
spatialReference
>>> r['candidates']
[{'attributes': {'South_Lat': '45.9109001', 'North_Lat': '45.9328003', 'MatchLevel': 'city', 'West_Lon': '6.6802702', 'Score': 81, 'East_Lon': '6.73383'}, 'score': 81, 'location': {'y': 47.923488599999999, 'x': 3.6858501000000001}, 'address': 'Paris, ile de france75110 Paris, FRA'}]
>>> r['spatialReference']
{'wkid': 4326}
>>> r['candidates'][0]
{'attributes': {'South_Lat': '45.9109001', 'North_Lat': '45.9328003', 'MatchLevel': 'city', 'West_Lon': '6.6802702', 'Score': 81, 'East_Lon': '6.73383'}, 'score': 81, 'location': {'y': 47.923488599999999, 'x': 3.6858501000000001}, 'address': 'Paris, ile de france75110 Paris, FRA'}
>>> r['candidates'][0]['location']
{'y': 47.923488599999999, 'x': 3.6858501000000001}
>>> r['candidates'][0]['location']['y']
47.923488599999999
>>> r['candidates'][0]['score']
81
>>> r['candidates'][0]['location']
{'y': 47.923488599999999, 'x': 3.6858501000000001}
>>> r['candidates'][0]['attributes']['MatchLevel']
'city' |
Partager