1

I have a zipcode, but I don't know the country reference. The zipcode could refer to Spain, France or Mexico (or other countries).

from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="geoapiExercises")
location = geolocator.geocode("30500", addressdetails=True, country_codes = ['ES, FR, MX'])
print(location)
print(location.raw['address'])

The problem is that when I use this code with the geopy module in python, it only returns the first argument (Spain in this case). I would like to return the information in a dictionary by country code and then choose based on external decisions.

dict={}
{"Molina de Segura, Vega Media del Segura, Región de Murcia, 30500, España",
"Saint-Victor-de-Malcap, Alès, Gard, Occitanie, France métropolitaine, 30500, France",
"Tonalá, Chiapas, 30500, México"}
Carola
  • 366
  • 4
  • 18

0 Answers0