字符编码

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'\xe4\xb8\x80\xe4\xba\x8c\xe4\xb8\x89\xe5\x9b\x9b'
3 一二三四

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

posted @ 2017-10-10 15:30  橙子味的萝卜  阅读(168)  评论(0编辑  收藏  举报