首页 > 编程语言 > 详细

python encode decode

时间:2020-10-28 09:12:20      阅读:33      评论:0      收藏:0      [点我收藏+]
 1 str = "Wie geht‘s dir für"
 2 print(str)
 3 str2 = str.encode(encoding=UTF-8)
 4 print(str2)
 5 str3 = str2.decode(encoding=UTF-8)
 6 print(str3)
 7 
 8 str = "你好呀"
 9 print(str)
10 str2 = str.encode(encoding=UTF-8)
11 print(str2)
12 str3 = str2.decode(encoding=UTF-8)
13 print(str3)

输出结果

Wie geht‘s dir für
b"Wie geht‘s dir f\xc3\xbcr"
Wie geht‘s dir für
你好呀
b‘\xe4\xbd\xa0\xe5\xa5\xbd\xe5\x91\x80‘
你好呀

 

utf-8和unicode的区别

python encode decode

原文:https://www.cnblogs.com/cydcyd/p/13888619.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!