成功解决AttributeError: ‘str‘ object has no attribute ‘decode‘
生活随笔
收集整理的這篇文章主要介紹了
成功解决AttributeError: ‘str‘ object has no attribute ‘decode‘
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
成功解決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‘的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: NLP之TM:基于gensim库调用20
- 下一篇: Paper之Algorithms:国内外