Python 3 JSON-API abrufen und analysieren
Wie würde ich eine JSON-API-Antwort mit Python analysieren? Ich habe momentan folgendes:
import urllib.request
import json
url = 'https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty'
def response(url):
with urllib.request.urlopen(url) as response:
return response.read()
res = response(url)
print(json.loads(res))
Ich erhalte folgenden Fehler: TypeError: Das JSON-Objekt muss str sein, nicht 'bytes'
Was ist die pythonische Art, mit json apis umzugehen?