1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > Python中使用Unicode对中文进行编码和解码

Python中使用Unicode对中文进行编码和解码

时间:2024-03-26 03:55:30

相关推荐

Python中使用Unicode对中文进行编码和解码

编码

str = 'Python才是世界上最好的语言'.encode('unicode_escape')print(str)

输出结果:

b'Python\\u624d\\u662f\\u4e16\\u754c\\u4e0a\\u6700\\u597d\\u7684\\u8bed\\u8a00

解码

str = 'Python\\u624d\\u662f\\u4e16\\u754c\\u4e0a\\u6700\\u597d\\u7684\\u8bed\\u8a00'print(str.encode('utf8').decode('unicode_escape'))

输出结果:

Python才是世界上最好的语言

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。