python3报错:TypeError: can't concat bytes to str

Posted 那时的吻狠陶醉

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python3报错:TypeError: can't concat bytes to str相关的知识,希望对你有一定的参考价值。

有时会报错这个:TypeError: Can‘t convert ‘bytes‘ object to str implicitly

解决方法:使用字节码的decode()方法。

示例:

str = ‘I am string‘
byte = b‘ I am bytes‘
s = str + byte
print(s)

  这时会报错:TypeError: Can‘t convert ‘bytes‘ object to str implicitly

解决方法:

s = str + byte.decode()

  

 

以上是关于python3报错:TypeError: can't concat bytes to str的主要内容,如果未能解决你的问题,请参考以下文章