首页 > 编程语言 > 详细

python str byte 互转

时间:2019-10-17 13:27:41      阅读:65      评论:0      收藏:0      [点我收藏+]

 

 

# bytes object  
 b = b"example"  
  
 # str object  
 s = "example"  
  
 # str to bytes  
 bytes(s, encoding = "utf8")  
  
 # bytes to str  
 str(b, encoding = "utf-8")  
  
 # an alternative method  
 # str to bytes  
 str.encode(s)  
  
 # bytes to str  
 bytes.decode(b)

 

python str byte 互转

原文:https://www.cnblogs.com/lshan/p/11691309.html

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