Python Forum
Thread Rating:
  • 2 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not sure how to debug this?
#4
You know that the url address is wrong googleis?
API doc.
For this use Requests.

Here a demo,i use string formatting to make changes in url address.
import requests

address = '1600 Amphitheatre Parkway Mountain View'
api_key = 'Your API key'
url = 'https://maps.googleapis.com/maps/api/geocode/json?address={}{}'.format(''.join(address.split()), api_key)
url_get = requests.get(url)
loc = url_get.json()
What you get back is a Python dictionary also contain list when come from JSON.
Test run.
>>> loc['results'][0]['geometry']
{'bounds': {'northeast': {'lat': 37.42198310000001, 'lng': -122.0853195},
            'southwest': {'lat': 37.4214139, 'lng': -122.0860042}},
 'location': {'lat': 37.4216548, 'lng': -122.0856374},
 'location_type': 'ROOFTOP',
 'viewport': {'northeast': {'lat': 37.4230474802915, 'lng': -122.0843128697085},
              'southwest': {'lat': 37.4203495197085,
                            'lng': -122.0870108302915}}}

>>> loc['results'][0]['geometry']['location']
{'lat': 37.4216548, 'lng': -122.0856374}

>>> loc['results'][0]['geometry']['location']['lat']
37.4216548
Reply


Messages In This Thread
Not sure how to debug this? - by rsmldmv - Nov-08-2017, 04:48 AM
RE: Not sure how to debug this? - by buran - Nov-08-2017, 05:19 AM
RE: Not sure how to debug this? - by rsmldmv - Nov-09-2017, 12:31 AM
RE: Not sure how to debug this? - by snippsat - Nov-09-2017, 02:51 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  pycharm debug help mg24 1 1,143 Nov-18-2022, 05:38 AM
Last Post: deanhystad
  Python debug suddenly got bad ben1122 3 1,193 Sep-03-2022, 06:20 AM
Last Post: ben1122
Bug Help Debug please jamesaarr 12 4,087 Jul-28-2021, 11:20 PM
Last Post: Pedroski55
  Error in Int object is not subscript-able. How to debug this ? yanDvator 1 2,292 Aug-03-2020, 02:28 PM
Last Post: Larz60+
  is there a debug mode available while creating python egg BhushanPathak 1 2,438 Dec-19-2018, 04:15 PM
Last Post: Larz60+
  Help debug my fibonacci implementation dineshpabbi10 6 4,141 May-16-2018, 12:12 PM
Last Post: dineshpabbi10
  Debug and trace in python quocchi22101262 0 3,555 Jun-20-2017, 09:35 AM
Last Post: quocchi22101262

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020