python编码解码

来源:互联网 发布:微信假红包软件生成器 编辑:程序博客网 时间:2024/05/21 09:32
#-*-coding:utf-8-*- #__author:martin#date:2017/10/21s = 'hello可乐'#编码  str类型 ---> 16进制bytes类型b = s.encode('utf8')print(type(b))print(b)#b'hello\xe8\x99\x8e'#解码  16进制bytes类型--->str类型 s_n = str(b,'utf8')print(s_n)