strings 分别在 Python2、Python 3下
Python 2 将 strings 处理为原生的 bytes 类型,而不是 unicode,
Python 3 所有的 strings 均是 unicode 类型。
![](https://images2017.cnblogs.com/blog/529876/201801/529876-20180116091603990-537361441.png)
msg = '您好' # encode 将strings编码成bytes print(msg.encode('utf-8')) # decode 将bytes 解码成strings print(b'xe6x82xa8xe5xa5xbd'.decode('utf-8'))
print 结果