属于某个位置的国家(python)?

问题描述 投票:0回答:1

通过

Given the lat/long coordinates, how can we find out the city/country?

我试图从坐标中获取信息,并且可以正常工作,正如Farsheed在python中所写的那样。但是我只能得到国家作为答案,它是否存在这样的属性来赋予“位置”变量?

python location geopy
1个回答
0
投票
>>> from geopy.geocoders import Nominatim
>>> geolocator = Nominatim(user_agent="specify_your_app_name_here")
>>> location = geolocator.reverse("52.509669, 13.376294")
>>> print(location.address)
Potsdamer Platz, Mitte, Berlin, 10117, Deutschland, European Union
>>> print((location.latitude, location.longitude))
(52.5094982, 13.3765983)
>>> print(location.raw)
{'place_id': '654513', 'osm_type': 'node', ...}
© www.soinside.com 2019 - 2024. All rights reserved.