首页 > 编程语言 > 详细

[2016-01-18][python][查询IP所在地]

时间:2016-01-18 11:50:57      阅读:152      评论:0      收藏:0      [点我收藏+]
[2016-01-18][python][查询IP所在地]


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from urllib import request
import json
def GetIPCity(ip,city):
    with request.urlopen("http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip="+ip) as f:
           data = f.read()
    st = json.loads(data.decode(‘utf-8‘))
    city[0= st[‘country‘]
    city[1= st[‘province‘]
    city[2= st[‘city‘]
 
 
city = ["","",""]
ip = "183.62.57.244"
GetIPCity(ip,city)
print(city)




[2016-01-18][python][查询IP所在地]

原文:http://www.cnblogs.com/qhy285571052/p/5138561.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!