以下代码,
import urllib response=urllib.urlopen('http://www.zhihu.com') html=response.read() print(html)
运行报错"AttributeError: module 'urllib' has no attribute 'urlopen'
原因:Python3.6中应该用urllib.request。更改后就不会再出现这个错误了
import urllib.request response=urllib.request.urlopen('http://www.zhihu.com') html=response.read() print(html)