Python反向地理编码从';谷歌地图';

Python反向地理编码从';谷歌地图';,python,google-maps,reverse-geocoding,geocoder,Python,Google Maps,Reverse Geocoding,Geocoder,我一直在尝试对lat和long数据的csv进行反向地理编码,以找到与坐标对应的邮政编码。我有一个来自谷歌的API,并尝试使用pygeocoder,但它无法识别API(见下面的代码) 每次我收到并出错: GeocoderError: Error REQUEST_DENIED Query: https://maps.google.com/maps/api/geocode/json?region=&latlng=51.495290%2C-0.166223&sensor=false&am

我一直在尝试对lat和long数据的csv进行反向地理编码,以找到与坐标对应的邮政编码。我有一个来自谷歌的API,并尝试使用pygeocoder,但它无法识别API(见下面的代码)

每次我收到并出错:

GeocoderError: Error REQUEST_DENIED
Query: https://maps.google.com/maps/api/geocode/json?region=&latlng=51.495290%2C-0.166223&sensor=false&bounds=&language=
然后我使用谷歌地图软件包:

import googlemaps 
import pandas as pd

gmaps = googlemaps.Client(key='my API')

lndn = pd.read_csv(r'my file pathway', sep=',')

results = gmaps.reverse_geocode((lndn['lat'][0], lndn['lng'][0]))

results 

这是可行的,但只是打印了所有信息,即

[{u'address_components': [{u'long_name': u'35',
    u'short_name': u'35',
    u'types': [u'street_number']},
   {u'long_name': u'Walton Street',
    u'short_name': u'Walton St',
    u'types': [u'route']},
   {u'long_name': u'Chelsea',
    u'short_name': u'Chelsea',
    u'types': [u'neighborhood', u'political']},
   {u'long_name': u'London',
    u'short_name': u'London',
    u'types': [u'postal_town']},
   {u'long_name': u'Greater London',
    u'short_name': u'Greater London',
    u'types': [u'administrative_area_level_2', u'political']},
   {u'long_name': u'England', etc............

我能看到里面有邮政编码。有没有办法从这些文件中提取和打印邮政编码?

如果您不介意使用库

这将打印出一个没有所有值的unicode“u”的字典

[{u'address_components': [{u'long_name': u'35',
    u'short_name': u'35',
    u'types': [u'street_number']},
   {u'long_name': u'Walton Street',
    u'short_name': u'Walton St',
    u'types': [u'route']},
   {u'long_name': u'Chelsea',
    u'short_name': u'Chelsea',
    u'types': [u'neighborhood', u'political']},
   {u'long_name': u'London',
    u'short_name': u'London',
    u'types': [u'postal_town']},
   {u'long_name': u'Greater London',
    u'short_name': u'Greater London',
    u'types': [u'administrative_area_level_2', u'political']},
   {u'long_name': u'England', etc............
import json, ast
x = ast.literal_eval(json.dumps(vals))

for i in x:
    print(i)