Python3.X识别混合编码,顺便解决“AttributeError: 'module' object has no attribute 'urlopen'”
2017-03-03 15:46
1241 查看
原本是想利用chardet模块识别一个混合编码网页的编码类型(以百度为例),然而运行脚本发现python3.X中出现“AttributeError: 'module' object has no attribute 'urlopen'就顺便说下子:
测试代码:
出现如下报错:
原因是python3.X把urllib模块拆分成了urllib.request和urllib.error,导入模块的时候应该import到具体的包:
测试代码:
出现如下报错:
原因是python3.X把urllib模块拆分成了urllib.request和urllib.error,导入模块的时候应该import到具体的包:
相关文章推荐
- python错误:AttributeError: 'module' object has no attribute 'setdefaultencoding'问题的解决方法
- Python基础学习-'module' object has no attribute 'urlopen'解决方法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- 【python学习笔记(2)】脚本报错"AttributeError: 'module' object has no attribute 'xxx'"解决方法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- python错误:AttributeError: 'module' object has no attribute 'setdefaultencoding'问题的解决方法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- Python3.x中出现 "AttributeError: module 'urllib' has no attribute 'urlopen'" 的解决方法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- python3 报错: AttributeError: 'module' object has no attribute 'urlopen'
- 解决Python报错: AttributeError: 'module' object has no attribute '_base'
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- python AttributeError: 'module' object has no attribute 'dumps'解决办法
- AttributeError: 'module' object has no attribute 的解决方法