Discuss / Python / <urllib>作业

<urllib>作业

Topic source

Gin阿金

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

#homework from urllib import request import json

def fetch_data(url):
with request.urlopen(url) as f: data = f.read() Data = data.decode('utf-8') return json.loads(Data)

测试

URL = 'http://news-at.zhihu.com/api/4/news/latest' data = fetch_data(URL) print(data)


  • 1

Reply