Created
February 17, 2020 01:40
-
-
Save e96031413/362b64dee62ab9b8f78897c9cc4044c4 to your computer and use it in GitHub Desktop.
Get your Country, City, Lat, Log with Python (require requests only)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
res = requests.get('https://ipinfo.io/') | |
data = res.json() | |
#print(data) | |
location = data['loc'].split(',') | |
city=data['city'] | |
country=data['country'] | |
lat=float(location[0]) | |
log=float(location[1]) | |
print("國家:",country,"城市:",city,"緯度:",lat,"經度:",log) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment