Discuss / Python / 作业

作业

Topic source

EddieLau_

#1 Created at ... [Delete] [Delete and Lock User]
import json

def fetch_data(url):
    req = request.Request(url)
    with request.urlopen(req) as f:
        if not f.status == 200: raise ValueError('请求失败')
        return json.loads(f.read().decode('utf-8'))

  • 1

Reply