Python3報錯:TypeError: Can’t convert ‘bytes’ object to str implicitly

該問題主要常見於Python2代碼向Python3的移植過程當中,由於Python3中是有bytes類型的,但在Python 2中它仍是用string類型來表示。web # string to bytes a = 'abcd' print(a) b = a.encode() print(b) ###輸出 abcd b'abcd' # bytes to string a = b'abcd' pr
相關文章
相關標籤/搜索