Sanket
Sanket

Reputation: 129

Python 3.3.5 - Get my current location's lat and long

I am working on a project which requires my current location's exact lat-long. I tried to run the code using Google Maps API as well as http://freegeoip.net/json on windows 7 machine, but nothing seems to take 'My current location' as an input and output the exact lat-long.

Can someone please help?

Thanks, Sanket.

Upvotes: 1

Views: 7621

Answers (1)

Balaraju M
Balaraju M

Reputation: 483

This is very simple. You can try this one

first, you need to install the geocoder module

pip install geocoder

Then you can try this one

import geocoder
myloc = geocoder.ip('me')
print(myloc.latlng)

Upvotes: 5

Related Questions