首页 > 编程语言 > 详细

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

时间:2018-01-18 16:05:48      阅读:2971      评论:0      收藏:0      [点我收藏+]

有时会报错这个: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

原文:https://www.cnblogs.com/fh-fendou/p/8310425.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!