所以,这很奇怪。我正在尝试让一个脚本在我的 RaspberryPi 上运行,以从weatherunderground 的 JSON 流中获取天气数据。我正在最新的 Raspbian-Stretch OS 上的新 Raspberry Pi 上使用 Python3.5。它在其他机器上运行时有效(通过 VisualStudio 和另一个运行相同发行版的 Raspberry Pi 和 LEDES 发行版上的 Onion Omega2 的 Windows)
我正在阅读的行(从本网站上的其他搜索中编辑)是:
import urllib.request
import json
# Get and load the weather data from my house weather station.
weatherdata = urllib.request.urlretrieve("http://api.wunderground.com/api/<myAPIKey-hidden here>/conditions/q/pws:KKYLOUIS68.json")
weatherinfo = json.loads(weatherdata.read())
从外壳返回是这样的:
Traceback (most recent call last):
File "/home/pi/myweather_win.py", line 18, in <module>
weatherinfo = json.loads(weatherdata.read())
AttributeError: 'tuple' object has no attribute 'read'
我不是程序员,只是想学习,这让我很难过,因为它可以在其他系统上运行。
三国纷争
GCT1015
相关分类