【发布时间】:2017-10-18 11:52:03
【问题描述】:
我正在尝试使用 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 以他们的国家语言返回城市和国家名称,例如:
city: Berlin, country: Deutschland
city: København, country: Danmark
city: București, country: România
我希望他们是这样的:
city: Berlin, country: Germany
city: Copenhagen, country: Denmark
city: Bucharest, country: Romania
是否可以按照我的意愿使用英语?或以某种方式转换它们?我正在使用世界上所有国家和城市。
【问题讨论】: