字符编码

1 msg = "一二三四"
2 a = msg.encode(encoding="utf-8")
3 b = msg.encode(encoding="utf-8").decode(encoding="utf-8")
4 
5 print(msg)
6 print(a)
7 print(b)

输出结果:

1 一二三四
2 b'xe4xb8x80xe4xbax8cxe4xb8x89xe5x9bx9b'
3 一二三四

 详细参考文章:http://www.cnblogs.com/alex3714/articles/7550940.html

原文地址:https://www.cnblogs.com/jesse-gong/p/7645889.html