如何用python解析json api响应?
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))
I'm getting this error: TypeError: the JSON object must be str, not 'bytes'
处理jsonAPI的Python方式是什么?