打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
成功解决AttributeError: ''str'' object has no attribute ''decode''

解决问题

AttributeError: 'str' object has no attribute 'decode'

解决思路

根据问题提示,意思是,属性错误:“str”对象没有属性“decode”
python3.5和Python2.7在套接字返回值解码上的区别 
python在bytes和str两种类型转换,所需要的函数依次是encode(),decode()

解决方法

直接去掉decode('utf8')

tips:str通过encode()方法可以编码为指定的bytes。反过来,当从网络或磁盘上读取了字节流,那么读到的数据就是bytes。要把bytes变为str,就需要用decode()方法。反之,则使用encode()方法即可!

大功告成!

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
专业在线电子书网站
python str与byte转换 encode decode
AttributeError: 'str' object has no attribute 'decode'
Tensorflow AttributeError: 'NoneType' object has no attribute 'TF_DeleteStatus'
python整数、字符串、字节串相互转换 | Lixingcong
python3大作战之encode与decode讲解
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服