python3 str和bytes转换

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) 
posted on 2017-09-05 22:52  神秘藏宝室  阅读(191)  评论(0编辑  收藏  举报

 >>>转载请注明出处<<<