码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2018-01-18 17:22:03      阅读:9560      评论:0      收藏:0      [点我收藏+]

标签:can   error:   object   解决   gpo   使用   方法   cat   pos   

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

标签:can   error:   object   解决   gpo   使用   方法   cat   pos   

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

(1)
(1)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!