我正在尝试使用geopy获取城市和国家名称。
通常情况下,您可以使用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'])
这是输出内容:
{'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
有没有可能以英文获取它们?或者以某种方式转换它们?我正在使用全球各个国家和城市。