title: Using Google Maps geocoder from Python with urllib2
body: <p>I'm trying to use the Google Maps geocoder with Python and JSON, but keep being told I have a bad request: </p>
  
  <pre><code>add = "Buckingham Palace, London, SW1A 1AA"
  geocode_url = "https://maps.googleapis.com/maps/api/geocode/json?address=%s&amp;sensor=false&amp;region=uk" % add
  print geocode_url
  req = urllib2.urlopen(geocode_url)
  jsonResponse = json.loads(f.read())
  pprint.pprint(nest) 
  </code></pre>
  
  <p>This fails with <code>urllib2.HTTPError: HTTP Error 400: Bad Request</code>. </p>
  
  <p>But if I simply copy and paste </p>
  
  <pre><code>https://maps.googleapis.com/maps/api/geocode/json?address=Buckingham%20Palace,%20London,%20SW1A%201AA&amp;sensor=false&amp;region=uk
  </code></pre>
  
  <p>into a browser bar, it works fine.</p>
  
  <p>What is wrong with my request?</p>