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()

  

 

文章来自:https://www.cnblogs.com/fh-fendou/p/8310425.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3