我想用geopy找到城市和国家的名字。在
通常情况下,这就是如何使用geopy获取城市和国家的信息。在from geopy.geocoders import Nominatim
geolocator = Nominatim(timeout=3)
geolocator.reverse('52.5094982,13.3765983')
loc = location.raw
loc_dict = location.raw
print(loc_dict['address'])
and this is the output:
{'suburb': 'Tiergarten', 'country_code': 'de', 'country': 'Deutschland', 'postcode': '10117', 'attraction': 'Potsdamer Platz', 'road': 'Potsdamer Platz', 'city': 'Berlin', 'city_district': 'Mitte', 'state': 'Berlin'}
我的问题是geopy用国家语言返回城市和国家名称,例如:
^{pr2}$
我想要这样的:city: Berlin, country: Germany
city: Copenhagen, country: Denmark
city: Bucharest, country: Romania
有可能按我的要求用英语写吗?或者以某种方式改变他们?我使用的是世界上所有的国家和城市。在