<p>以防有人仍然有同样的问题。您还可以从<code>Nominatim()</code>geocoder(geopy的标准开源geocoder)获取各个地址组件。</p>
<pre><code>from geopy.geocoders import Nominatim
# address is a String e.g. 'Berlin, Germany'
# addressdetails=True does the magic and gives you also the details
location = geolocator.geocode(address, addressdetails=True)
print(location.raw)
</code></pre>
<p>给予</p>
<pre><code>{'type': 'house',
'class': 'place',
'licence': 'Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright',
'display_name': '2, Stralauer Allee, Fhain, Friedrichshain-Kreuzberg, Berlin, 10245, Deutschland',
'place_id': '35120946',
'osm_id': '2825035484',
'lon': '13.4489063',
'osm_type': 'node',
'address': {'country_code': 'de',
'road': 'Stralauer Allee',
'postcode': '10245',
'house_number': '2',
'state': 'Berlin',
'country': 'Deutschland',
'suburb': 'Fhain',
'city_district': 'Friedrichshain-Kreuzberg'},
'lat': '52.5018003',
'importance': 0.421,
'boundingbox': ['52.5017503', '52.5018503', '13.4488563', '13.4489563']}
</code></pre>
<p>与</p>
<pre><code>location.raw['address']
</code></pre>
<p>你得到的字典只有组件。</p>
<p>查看<a href="http://geopy.readthedocs.io/en/1.10.0/#geopy.geocoders.Nominatim" rel="noreferrer">geopy documentation</a>以获取更多参数,或查看<a href="http://wiki.openstreetmap.org/wiki/Nominatim" rel="noreferrer">Nominatim</a>以获取所有地址组件。</p>
<p>希望我能帮助每一个有困难的人。也许别人更容易找到这个答案,因为我认为这是这个问题的正确答案。</p>