在python2中使用的urllib2库在python3中不存在怎么解决呢?在python3中是urllib.request.urlopen代替了urllib2.
import urllib.request
def download(url):
reponse = urllib.request.urlopen(url,timeout=5)
# urllib.request.Request(url,headers=)
print(type(reponse))
print(reponse.info())
download('https://baidu.com')
最后打印结果
1.png
网友评论