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

目录

​解决问题​

​解决思路​

​解决方法​

​T1、直接去掉​

​T2、众多网友好评的建议​


解决问题

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

解决思路

根据问题提示,意思是,属性错误:“str”对象没有属性“decode”

python3.5和Python2.7在套接字返回值解码上的区别 

python在bytes和str两种类型转换,所需要的函数依次是encode(),decode()

解决方法

T1、直接去掉

直接去掉decode('utf8')

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

T2、众多网友好评的建议

谢谢 improve100 网友提供的建议!

pip install 'h5py<3.0.0' -i https://pypi.tuna.tsinghua.edu.cn/simple

成功解决AttributeError: ‘str‘ object has no attribute ‘decode‘_解决方法

大功告成!

成功解决AttributeError: ‘str‘ object has no attribute ‘decode‘_python_02