Python3.x:报错POST data should be bytes, an iterable of bytes
Python3.x:报错POST data should be bytes, an iterable of bytes
问题:
python3.x:报错
POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.
原因:
# 组装GET方法的请求
request = urllib2.Request(url, data, headers)
其中的data需要转为utf-8
解决方案:
# 组装GET方法的请求
#将代码request = urllib2.Request(url, data, headers) 更改为
request = urllib.request.Request(url, data=urllib.parse.urlencode(data).encode(encoding='UTF8'), headers=headers)
Python3.x:报错POST data should be bytes, an iterable of bytes的更多相关文章
- ELK之kibana的web报错[request] Data too large, data for [<agg [2]>] would be larger than limit of
http://blog.51cto.com/11819159/1926411 ELK架构:elasticsearch+kibana+filebeat 版本信息: elasticsearch 5.2.1 ...
- centos7中python3.6报错ModuleNotFoundError: No module named '_ssl' 或者 Max retries exceeded with url: / (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",))
如果在运行爬虫时报此错:requests.exceptions.SSLError: HTTPSConnectionPool(host='www.baidu.com', port=443): Max r ...
- Python3+selenium 报错处理:“selenium.common.exceptions.NoAlertPresentException: Message: No alert is active”
一.说明 在使用python3+selenium写自动升级程序的时侯,碰到一个弹出对话框需要点击确认的场景.弹出的对话框如下图所示. 对于弹框各种资料都说通过switch_to.alert属性获取对话 ...
- grasshopper | 通过图层引用线条 报错:“ Data conversion failed from Guid to Curve ”的避免方法
需求:通过 LunchBox - > layer reference 电池 可以快速选中图层所在的线条,但是选择的数据流错误 直接选择会报错--"Data conversion fai ...
- C# UTF8的BOM导致XML序列化与反序列化报错:Data at the root level is invalid. Line 1, position 1.
最近在写一个xml序列化及反序列化实现时碰到个问题,大致类似下面的代码: class Program { static void Main1(string[] args) { var test = n ...
- python3 tkinter报错:_tkinter.TclError: cannot use geometry manager pack inside . which already has slaves managed by grid
报错: _tkinter.TclError: cannot use geometry manager pack inside . which already has slaves managed by ...
- CentOS7.5安装Python3.7报错:configure: error: no acceptable C compiler found in $PATH --Python3
1.问题解析 报错信息中有这样一条:configure: error: no acceptable C compiler found in $PATH即:配置错误,在$path中找不到可接受的C编译器 ...
- python3+django报错testserver
manage.py testserver --addrport 127.0.0.1 报错 查看其它项目 manage.py runserver --addrport 127.0.0.1 正常 查找配置 ...
- [已解决]报错:xlrd.compdoc.CompDocError: Workbook: size exceeds expected 17920 bytes; corrupt?
报错代码如下: filePath='test.xls' data=pd.read_excel(filePath) print(data.head()) 报错内容如下: Traceback (most ...
随机推荐
- Python全栈day13(作业讲解根据用户输入选择输出字典内容)
题目,有一个动植物对应的字典内容如下,请根据用户输入列出对应的动物或者植物,实现字典三级菜单功能 dic = { "植物": {"草本植物": ["牵 ...
- HDU_5532_Almost Sorted Array
Almost Sorted Array Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Ot ...
- HDU5667—Sequence(对数转化)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5667 题目意思:f1=1,i=1 f2=2 ,i=2 fi=a^b*f[i-1]^c*f[i-2] i ...
- ansible-puppet-saltstack---ITAMS
ansible http://www.cnblogs.com/ee900222/p/ansible.html http://ju.outofmemory.cn/entry/67581 http://w ...
- 6.2 - BBS + BLOG系统
一.简介 博客系统开发: 1.注册,登录,首页 2.个人站点,分组:(分类,标签,归档)3.文章详细页4.点赞,踩灭5.评论楼,评论树6.后台管理,发布文章,文件上传7.BeautifulSoup8. ...
- SpringBoot 与缓存
1. JSR107 Java Caching 定义了5个核心接口: CachingProvider:定义了创建,配置,获取,管理和控制多个CacheManager; CacheManager:定义了创 ...
- 剑指Offer——翻转单词顺序列
题目描述: 牛客最近来了一个新员工Fish,每天早晨总是会拿着一本英文杂志,写些句子在本子上.同事Cat对Fish写的内容颇感兴趣,有一天他向Fish借来翻看,但却读不懂它的意思.例如,“studen ...
- Mad Counting---LightOJ1148(好任性的过了)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1148 已知有n个人,并且每个人都知道除自己之外还有m个人与自己支持的队一样,让我们求至 ...
- 对Numpy数组按axis运算的理解
Python的Numpy数组运算中,有时会出现按axis进行运算的情况,如 >>> x = np.array([[1, 1], [2, 2]]) >>> x arr ...
- C++入门(2)
第一个程序,输入输出: #include <iostream> using namespace std; int main() { cout << "Hello, w ...