python中报错a bytes-like object is required, not 'str'解决办法
2019-02-23 09:34
1096 查看
报的错误其实就是函数需要bytes类型数据,但输入的是str型,提供两种解决方式
一.bytes变为str类型
s=s.decode()
s=str(s,encoding='utf-8')
s=bytes.decode(s)
二.str变为bytes
s=bytes(s,encoding='utf-8')
s=s.encode(s)
s=s.encode(encoding='utf-8')
相关文章推荐
- 解决python3的pickle.load错误:a bytes-like object is required, not 'str'
- python 保存scv文件乱码与报错的问题解决TypeError: a bytes-like object is required, not 'str'
- python3中,socket使用send函数时出现的错误:TypeError: a bytes-like object is required, not 'str'
- python中Base64编码和解码:TypeError: a bytes-like object is required, not 'str'
- python3 TypeError: a bytes-like object is required, not 'str'
- Python中3+版本运行2+版本程序出现TypeError: a bytes-like object is required, not 'str'之读取PDF中的图片
- Python学习中出现TpyeErrora bytes-like object is required, not 'str'
- Python中“a bytes-like object is required, not 'str'”的问题
- python 3.5: TypeError: a bytes-like object is required, not 'str' when writing to a file
- python3 套接字异常(a byte-like object is required not str)
- python2.7代码在python3.5环境下TypeError: a bytes-like object is required, not 'str'问题
- Python学习中出现TpyeErrora bytes-like object is required, not 'str'
- python3 套接字异常(a byte-like object is required not str)
- python3 TypeError: a bytes-like object is required, not 'str'
- Python 3.x Error: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'
- UDP通讯解决a bytes-like object is required, not 'str' 问题
- Python 3.5 Socket TypeError: a bytes-like object is required, not 'str' 错误提示
- python socket send 函数 报错:TypeError: a bytes-like object is required, not 'str'