Skip to content

Instantly share code, notes, and snippets.

@e96031413
Created February 17, 2020 01:40
Show Gist options
  • Save e96031413/362b64dee62ab9b8f78897c9cc4044c4 to your computer and use it in GitHub Desktop.
Save e96031413/362b64dee62ab9b8f78897c9cc4044c4 to your computer and use it in GitHub Desktop.
Get your Country, City, Lat, Log with Python (require requests only)
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