I want to extract distance from google distance matrix API in Python. The objet it returned is a python dictionary.
{'destination_addresses': [Mumbai, Maharashtra, India '],'origin_addresses': ['Powai, Mumbai, Maharashtra, India'],'rows': [{'elements': [{'distance': {'text': u '47.1 km','value': 47086},'duration': {'text': '1 hour 17 mins','value': 4628},'status': 'OK'}]}],'status': 'OK'}
I want to extract the distance and duration from above. I have used
distance = my_distance["rows"]
for a in distance:result = a["elements"]print result
It gave me
[{u 'duration': {u 'text': u '1 hour 17 mins', u 'value': 4628}, u 'distance': {u 'text': u '47.1 km', u 'value': 47086}, u 'status': u 'OK'
}]
Now how to extract duration (1 hour 17 mins) and distance (47.1 km) and their corresponding values (4628 & 47086)