import json
from urllib import request
def fetch_data(url):
req=request.Request(url)
with request.urlopen(req) as f:
print('Status:',f.status,f.reason)
data=f.read()
return json.loads(data.decode('utf-8'))
题目中链接失效,所以测试通不过的,换了大家给的网址可以正常运行,但是测试代码不要再用了
Sign in to make a reply
是冬大瓜不是大冬瓜
import json
from urllib import request
def fetch_data(url):
req=request.Request(url)
with request.urlopen(req) as f:
print('Status:',f.status,f.reason)
data=f.read()
return json.loads(data.decode('utf-8'))
题目中链接失效,所以测试通不过的,换了大家给的网址可以正常运行,但是测试代码不要再用了