您的位置:首页 > 编程语言 > Python开发

python3.6 出现AttributeError: module 'urllib' has no attribute 'urlopen'

2018-03-26 07:01 746 查看
以下代码,
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)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐