python中Base64编码和解码:TypeError: a bytes-like object is required, not 'str'
2017-07-31 08:51
996 查看
在目前最新版本下出现问题
F:\p>python
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
#-*- coding: utf-8
import base64
str='cnblogs'
str64=base64.b64encode(str)
print(str64) #Y25ibG9ncw==
print(base64.b64decode(str64)) #cnblogs
正确修改str=b'cnblogs'
就能解决问题。
F:\p>python
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
#-*- coding: utf-8
import base64
str='cnblogs'
str64=base64.b64encode(str)
print(str64) #Y25ibG9ncw==
print(base64.b64decode(str64)) #cnblogs
正确修改str=b'cnblogs'
就能解决问题。
相关文章推荐
- python 3.5: TypeError: a bytes-like object is required, not 'str' when writing to a file
- Python 3.x Error:TypeError: a bytes-like object is required, not 'str'
- Python中3+版本运行2+版本程序出现TypeError: a bytes-like object is required, not 'str'之读取PDF中的图片
- Python 3.5 Socket TypeError: a bytes-like object is required, not 'str' 错误提示
- python write()参数错误,导致报错TypeError: a bytes-like object is required, not 'str'
- python3中,socket使用send函数时出现的错误:TypeError: a bytes-like object is required, not 'str'
- python3.5 模拟UDP客户端发送数据报文,报错:TypeError: a bytes-like object is required, not 'str'
- Python 3.x: TypeError: a bytes-like object is required, not 'str'
- python socket send 函数 报错:TypeError: a bytes-like object is required, not 'str'
- TypeError: a bytes-like object is required, not 'str'
- Python学习中出现TpyeErrora bytes-like object is required, not 'str'
- TypeError: a bytes-like object is required, not 'str'
- 【Python】TypeError: a bytes-like object is required, not 'str'解决
- 【Python】TypeError: a bytes-like object is required, not 'str'解决
- Error:a bytes-like object is required not str
- 解决python3的pickle.load错误:a bytes-like object is required, not 'str'
- python问题:TypeError: a bytes-like object is required, not 'str'
- Python 3.5 Socket TypeError: a bytes-like object is required, not 'str' 错误提示
- python 3.5: TypeError: a bytes-like object is required, not 'str'
- Python中“a bytes-like object is required, not 'str'”的问题