import json
import urllib2
response = urllib2.urlopen('http://www.energyhive.com/mobile_proxy/getCurrentValuesSummary?token=VtxgIC2UnhfUmXe_pBksov7-lguAQMZD')
content = response.read()
print(content)
从我得到的代码
[{"cid":"PWER","data":[{"1437957635000":37}],"sid":"9271","units":"kWm","age":6},{"cid":"PWER_GAC","data":[{"1437957635000":0}],"sid":"9271","units":null,"age":6},{"cid":"FBAK_IMM","data":[{"1437957629000":0}],"sid":"9271","units":null,"age":12},{"cid":"PWER_IMM","data":[{"1437957629000":0}],"sid":"9271","units":null,"age":12}]
我没办法从普华永道获得数据
您只需将其作为JSON加载并转到正确的键:
您正在接收的数据是一个字符串,您可以使用
json.loads()
将其转换为Python数据结构。然后遍历dict,直到cid与您要查找的内容匹配。你知道吗相关问题 更多 >
编程相关推荐