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 ...
随机推荐
- 666:放苹果(划分dp)
666:放苹果 查看 提交 统计 提问 总时间限制: 1000ms 内存限制: 65536kB 描述 把M个同样的苹果放在N个同样的盘子里,允许有的盘子空着不放,问共有多少种不同的分法?(用K表示 ...
- 170321、Spring+Quartz实现定时任务的配置方法
Quartz是Java版开源定时调度器. 核心概念: Job 表示一个工作,要执行的具体内容.此接口中只有一个方法 void execute(JobExecutionContext context): ...
- [iOS微博项目 - 4.3] - 设置每条微博边框样式
github: https://github.com/hellovoidworld/HVWWeibo A.设置每条微博边框样式 1.需求 不需要分割线 每个微博之间留有一定的间隙 2.思路 直接设 ...
- .c和.h的联系
.c文件就是C语言系列的源文件,而H文件则是C语言的头文件,即C系列中存放函数和全局变量的文件,因为C中的函数是被封装起来的,即无法看到其代码. 子程序不要定义在*.h中.函数定义要放在*.c中,而* ...
- Googlebot (Google Web search)
w推测“域名解析过程中,Google crawlers中首先是Googlebo中的Google Web search上阵”. +-----+----------------+------------- ...
- 【转】spring boot application.properties 配置参数详情
multipart multipart.enabled 开启上传支持(默认:true) multipart.file-size-threshold: 大于该值的文件会被写到磁盘上 multipart. ...
- python学习笔记(二)— 集合
s = set()#建立空的集合 s2 = {'}#没有:的为集合,集合天生去重 s3 = {'} #集合是也是无序的 # s2.add('a')#添加值 # s2.remove('2')#删除值 # ...
- git学习------>从SVN迁移到Git之后,项目开发代码继续在SVN提交,如何同步迁移之后继续在SVN提交的代码到Git?
最近逐步逐步的将公司的项目都从SVN往Git迁移了,但是想团队成员都能够一步到位就迁移到Git是不可能的,因为还有大部分人都还不会Git,所以整个过渡过程估计得大半年. 因此导致虽然项目迁移过来了,但 ...
- LightOJ1003---Drunk(拓扑排序判环)
One of my friends is always drunk. So, sometimes I get a bit confused whether he is drunk or not. So ...
- python手写神经网络实现识别手写数字
写在开头:这个实验和matlab手写神经网络实现识别手写数字一样. 实验说明 一直想自己写一个神经网络来实现手写数字的识别,而不是套用别人的框架.恰巧前几天,有幸从同学那拿到5000张已经贴好标签的手 ...