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)
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)
相关文章推荐
- Python 3.x中导入urllib出现AttributeError: module 'urllib' has no attribute 'urlopen'
- Python3.X出现AttributeError: module 'urllib' has no attribute 'urlopen'错误
- Python3.x中出现 "AttributeError: module 'urllib' has no attribute 'urlopen'" 的解决方法
- Python3.6 报错AttributeError: module 'urllib' has no attribute 'Request'
- Python2.7 安装mock出现AttributeError: 'module' object has no attribute的解决方法
- AttributeError: module 'urllib' has no attribute 'urlopen'
- Python 2.7.3 AttributeError: 'module' object has no attribute 'urlopen'
- python AttributeError: 'module' object has no attribute 'dumps'解决办法
- python3 报错: AttributeError: 'module' object has no attribute 'urlopen'
- 使用sae-python-dev本地运行web.py项目出现module object has no attribute InteractiveInterpreter
- Tensorflow出现AttributeError: module 'tensorflow' has no attribute 'constant'问题怎么办?
- 学习Python csv模块遇到AttributeError: module 'csv' has no attribute 'writer'和写入后出现空格问题
- python AttributeError: 'module' object has no attribute 'setdefaultencoding'
- Python3.X识别混合编码,顺便解决“AttributeError: 'module' object has no attribute 'urlopen'”
- Python报错——AttributeError: module 'PyQt5.QtGui' has no attribute 'QApplication'
- AttributeError: 'module' object has no attribute 'urlopen'
- web.py 启动时候出现AttributeError: 'module' object has no attribute 'inet_pton'错误
- python3.6脚本import json模块后,报错:AttributeError: module 'json' has no attribute 'dumps'
- python 中出现的AttributeError: 'module' object has no attribute '_handlerList'
- Python中module 'urllib' has no attribute 'openurl'问题