大家好,又见面了,我是你们的朋友全栈君。
成功解决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()方法即可!
谢谢 improve100 网友提供的建议!
pip install 'h5py<3.0.0' -i https://pypi.tuna.tsinghua.edu.cn/simple
大功告成!
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/160097.html原文链接:https://javaforall.cn
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有