Discuss / Python / 练习题

练习题

Topic source

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'))

题目中链接失效,所以测试通不过的,换了大家给的网址可以正常运行,但是测试代码不要再用了


  • 1

Reply