TypeError: expected bytes-like object, not str
报错内容:TypeError: expected bytes-like object, not str
例:
a = base64.b64encode(temp)
改为:
a = base64.b64encode(bytes(temp, 'utf-8'))
问题解决!
TypeError: expected bytes-like object, not str的更多相关文章
- Python之scrapy框架之post传输数据错误:TypeError: to_bytes must receive a unicode, str or bytes object, got int
错误名:TypeError: to_bytes must receive a unicode, str or bytes object, got int 错误翻译:类型错误:to_bytes必须接收u ...
- python中读取json文件报错,TypeError:the Json object must be str, bytes or bytearray,not ‘TextIOWrapper’
利用python中的json读取json文件时,因为错误使用了相应的方法导致报错:TypeError:the Json object must be str, bytes or bytearray,n ...
- python写入文本报错TypeError: expected a string or other character buffer object
今天用python写入文本, file_object2 = open('result.txt', 'w') file_object2.write(bookid_list) file_object2.c ...
- socket编程: TypeError: must be bytes or buffer, not str
先看一段代码 #!/usr/bin/env python3 from socket import * serverName = "10.10.10.132" serverPort ...
- 关于TypeError: strptime() argument 1 must be str, not bytes解析
关于TypeError: strptime() argument 1 must be str, not bytes解析 在使用datetime.strptime(s,fmt)来输出结果日期结果时, ...
- python TypeError: unsupported operand type(s) for +: 'geoprocessing value object' and 'str'
TypeError: unsupported operand type(s) for +: 'geoprocessing value object' and 'str' if self.params[ ...
- 导入json文件报错,TypeError expected string or buffer
导入json文件报错,TypeError expected string or buffer 原因:用字符串赋值后,python会把双引号转换为单引号 import json data = [{&qu ...
- 解决:error: Cannot fetch repo (TypeError: expected string or buffer)
同步源码,问题重现: Fetching project platform/external/libopus Fetching project repo error: Cannot fetch repo ...
- Python报错TypeError: '<' not supported between instances of 'str' and 'int'
n = input() if n>=100:print(int(n)/10) else:print(int(n)*10) 报错内容: Traceback (most recent call la ...
随机推荐
- 树莓派2-SSH
树莓派3系统SSH是默认关闭的, 将SD卡插入linux, 在root 分区, 修改/etc/rc.local 在exit 0前增加一行 /ect/init.d/ssh start 将SD卡插回树莓派 ...
- java 反射---学习笔记
一.java的动态性 反射机制 动态编译 动态执行JavaScript代码 动态字节码操作 二.动态语言 动态语言 程序运行时,可以改变程序结构或变量类型,典型的语言:python.ruby.java ...
- SPOJ GSS6 Can you answer these queries VI
Can you answer these queries VI Time Limit: 2000ms Memory Limit: 262144KB This problem will be judge ...
- 启的服务有时候突然报错:org.xml.sax.SAXParseException: schema_reference.4
记录一下,原文地址:http://blog.csdn.net/bluishglc/article/details/7596118
- 常见问题:Linux安装Python3步骤、Windows无法利用pip
Linux安装python3.6和第三方库的步骤: 我的Linux是CentOS 6.5版本 Linux下大部分系统默认自带python2.x的版本,最常见的是python2.6或python2.7, ...
- CRT(secureCRT)中文显示研究&Linux中文字符显示
关于secureCRT设置编码: 基本上只需要设置crt字符编码与远程服务器一致就可以了.要注意的是,有时设置完之后要重启secureCRT, 不然不会生效.
- msp430入门学习12
msp430的定时器--Timer_A(定时器A) msp430入门学习
- memcache适用和不适用场景[转载]
适用memcached的业务场景:1)如果网站包含了访问量很大的动态网页,因而数据库的负载将会很高.由于大部分数据库请求都是读操作,那么memcached可以显著地减小数据库负载.2)如果数据库服务器 ...
- Linux操作系统下IPTables配置
filter表的防火墙 1.查看本机关于IPTABLES的设置情况 [root@tp ~]# iptables -L -n Chain INPUT (policy ACCEPT) target pro ...
- Ubuntu12.04之修改密码
Ubuntu 12.04 默认root没有密码 修改密码方式如下: test@localhost:~$ sudo passwd root [sudo] password for test: 输入新的 ...