Python3.4 IP查询(api)
2016-01-19 21:06
796 查看
import urllib.request as requests import json ip = '106.33.128.216' key = '9cb9a1624edd4ae668d54ebbd7361628' url = "http://a.apix.cn/tongyu/iplookup/ip?ip=" + ip headers = { 'accept': "application/json", 'content-type': "application/json", 'apix-key': key } req = requests.Request(url, headers=headers) res = requests.urlopen(req).read().decode() str = json.loads(res)['data'] print(str) print(str['country'] + ' ' + str['province'] + '省' + str['city'] + '市 ' + str['operator'])
转载请注明作者与出处:http://blog.csdn.net/u013511642 王小涛_同學
相关文章推荐
- python 中 五种字典(dict)的遍历方法,实验法比较性能。
- python random.shuffle(随机打乱列表等) 和 random.random
- python实现一个朴素贝叶斯分类器
- 初学python--参数传递方式
- ubuntu14.04LTS下编译安装Open Babel和python语言绑定
- Python【基础第一篇】
- 【python】获取三维图形的某个截面
- webvtt字幕转srt字幕的python程序(附改名程序)
- Python-map()函数格式化不规则输入
- python 实现布尔莎转换模型
- Python-用filter()删除1~100的素数和一些思考
- python 下载整个站点
- Python字典的json格式化处理
- python threading的学习
- Python批量将excel文件转化为txt
- 使用Python处理目录(二):计算某个目录下特定文件类型中文件总行数
- 使用Python处理目录(一):打印目录下的文件名
- python string与list互转
- python简单爬虫--转源码
- python开发学习-day03(set集合、collection系列 、深浅拷贝、函数)