import re
from geopy.geocoders import Nominatim
from pprint import pprint
import pandas as pd
n = input ("Please write your current location":")
app = Nominatim(user_agent='tutorial')
location = app.geocode('{n}'.format(n=n))
pprint(location)
L = str(location)
displays information about the desired location.
Like this. How do I extract latitude and longitude (36.48217165, 127.30170843925583) only here?
python
Resolved.
You don't have to parse so complicatedly.
The attributes of the location are latitude and longitude.
print(location.latitude, location.longitude)
© 2024 OneMinuteCode. All rights reserved.