#!/usr/bin/pythonimport
urllib2import urllibimport
jsonweatherHtml = urllib.urlopen('http://172.17.37.93:1949/machine/select')
weatherHtml1 = weatherHtml.read()
weatherJSON = json.loads(weatherHtml1)
print weatherJSONout=open('/root/cmdb_ip','w')
for i in weatherJSON["data"]:
abc = i['privateIpAddress'] + "\n"
for key in abc:
out.write(key)
python 读取数据接口 ip 字段插入本地文件
原文:http://blog.51cto.com/breaklinux/2140481