Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Raspberry pi读取json类型错误';instancemethod';对象没有属性'__获取项目';_Python_Json_Raspberry Pi - Fatal编程技术网

Python Raspberry pi读取json类型错误';instancemethod';对象没有属性'__获取项目';

Python Raspberry pi读取json类型错误';instancemethod';对象没有属性'__获取项目';,python,json,raspberry-pi,Python,Json,Raspberry Pi,我在从Web服务器获取一些数据时遇到了问题,我想以json格式获取温度,然后将其解析为整数。我用python中的Raspberry Pi 3来尝试这个 到目前为止,守则是: import json, requests url='http://stationdata.wunderground.com/cgi-bin/stationlookup?station=IWIEN30&units=metric&v=2.0&format=json' r=requests.get(u

我在从Web服务器获取一些数据时遇到了问题,我想以json格式获取温度,然后将其解析为整数。我用python中的Raspberry Pi 3来尝试这个

到目前为止,守则是:

import json, requests

url='http://stationdata.wunderground.com/cgi-bin/stationlookup?station=IWIEN30&units=metric&v=2.0&format=json'

r=requests.get(url)
result =r.json
temperature = result['stations']['IWIEN30']['temperature']
temperature = int(temperature)
当我尝试执行此操作时,我得到:TypeError:'instancemethod'对象没有属性'getItem'

我对python和rasperry pi没有太多经验,所以我想我犯了一个愚蠢的错误
提前谢谢你

.json
是请求对象的方法;你需要给它打电话

result = r.json()