Python character extraction, latitude and longitude extraction with geopy.

Asked 2 years ago, Updated 2 years ago, 15 views

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

2022-09-20 18:00

2 Answers

Resolved.


2022-09-20 18:00

You don't have to parse so complicatedly.

The attributes of the location are latitude and longitude.

print(location.latitude, location.longitude)


2022-09-20 18:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.