码迷,mamicode.com
首页 > Web开发 > 详细

encode,decode,str to bytes

时间:2018-03-15 11:20:42      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:code   blog   type   gpo   utf-8   class   coding   log   odi   

msg = "你好,世界"
print(type(msg),msg)
msg1= msg.encode(encoding="utf-8")  #转换成bytes
print(type(msg1),msg1)
print(msg1.decode(encoding="utf-8")) #转换成str

  

encode,decode,str to bytes

标签:code   blog   type   gpo   utf-8   class   coding   log   odi   

原文地址:https://www.cnblogs.com/it-farmer123/p/8571508.html

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