#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2021/6/30 16:13 # @Author : h1code2 # @File : code.py # @Software: PyCharm # import module from geopy.geocoders import Nominatim # initialize Nominatim API geo_locator = Nominatim(user_agent="GoSpider") # Latitude & Longitude input Latitude = "25.124398793756" Longitude = "62.326154919175" location = geo_locator.reverse(Latitude + "," + Longitude, language="en") address = location.raw['address'] # traverse the data city = address.get('city', '') state = address.get('state', '') country = address.get('country', '') code = address.get('country_code') zipcode = address.get('postcode') print('City : ', city) print('State : ', state) print('Country : ', country) print('Zip Code : ', zipcode)