ich bin noch Neuling, was Python angeht und habe schon viel getestet.
Jetzt habe ich allerdings ein kleines Problem, mit dem ich nicht klar komme.
Ich möchte gerne die Daten aus dem JSON von OpenWeatherMap auslesen und hänge schon am Anfang.
Code: Alles auswählen
from urllib.request import urlopen
import json
json_string = urlopen("http://api.openweathermap.org/data/2.5/weather?id=6556947&units=metric&lang=de").read()
test=json.loads(json_string)
print(test['coord']['lon'])Code: Alles auswählen
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>
Traceback (most recent call last):
File "D:\Cloud\Cloud Station FH\Raspi\Python\MeinWetter\jsontest.py", line 6, in <module>
test=json.loads(json_string)
File "C:\Python34\lib\json\__init__.py", line 312, in loads
s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'
>>> Deshalb Frage ich die Profis hier einmal.
Hi2Helmi
