Python3.6 报错AttributeError: module 'urllib' has no attribute 'Request'
2018-03-26 07:26
489 查看
代码
import urllib
url = 'http://www.xxxxxx.com/login'
postdata = {'username': 'qiye', 'passsword': 'qiye_pass'}
data = urllib.parse.urlencode(postdata)
req = urllib.Request(url, data)
response = urllib.request.urlopen(req)
html = response.read()报错
AttributeError: module 'urllib' has no attribute 'Request'
解决方案
更改urllib.Request为urllib.Request为urllib.request.Request即可
import urllib
url = 'http://www.xxxxxx.com/login'
postdata = {'username': 'qiye', 'passsword': 'qiye_pass'}
data = urllib.parse.urlencode(postdata)
req = urllib.Request(url, data)
response = urllib.request.urlopen(req)
html = response.read()报错
AttributeError: module 'urllib' has no attribute 'Request'
解决方案
更改urllib.Request为urllib.Request为urllib.request.Request即可
相关文章推荐
- python错误 module 'urllib' has no attribute 'request'
- python3.6 出现AttributeError: module 'urllib' has no attribute 'urlopen'
- Python 3.x中导入urllib出现AttributeError: module 'urllib' has no attribute 'urlopen'
- [python错误]builtins.AttributeError: 'module' object has no attribute 'request'
- python文件名不要跟模块名相同,报错AttributeError: 'module' object has no attribute 'Differ'
- python3.6脚本import json模块后,报错:AttributeError: module 'json' has no attribute 'dumps'
- Python3.X出现AttributeError: module 'urllib' has no attribute 'urlopen'错误
- Python3.x中出现 "AttributeError: module 'urllib' has no attribute 'urlopen'" 的解决方法
- Python中module 'urllib' has no attribute 'openurl'问题
- python3:AttributeError: module 'urllib' has no attribute 'quote'
- 莫名其妙报module 'urllib' has no attribute 'request'的解决方法
- Python Matplotlib AttributeError: 'module' object has no attribute 'popall'
- 'module' object has no attribute 在python开发中出现的原因
- python 2.x和3.x关于 'module' object has no attribute 'open'的解决办法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- python爬虫框架scarpy之AttributeError: module 'scrapy' has no attribute 'spider'
- Python错误AttributeError: 'module' object has no attribute 'copy'
- python jieba 结巴分词报错 AttributeError: 'module' object has no attribute 'cut'
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- 【转载】C#调用python文件时出现'module' object has no attribute '_getframe'