直接看例子
In [10]: b'\u559c\u6b22\u4e00\u4e2a\u4eba'
Out[10]: b'\\u559c\\u6b22\\u4e00\\u4e2a\\u4eba'
In [11]: b'\u559c\u6b22\u4e00\u4e2a\u4eba'.decode('unicode_escape')
Out[11]: '喜欢一个人'
In [12]: '喜欢一个人'.encode('unicode_escape')
Out[12]: b'\\u559c\\u6b22\\u4e00\\u4e2a\\u4eba'
In [13]: '喜欢一个人'.encode('unicode_escape')
Out[13]: b'\\u559c\\u6b22\\u4e00\\u4e2a\\u4eba'
本文通过具体示例,展示了如何使用Python进行Unicode转义序列的解码和编码操作,揭示了文本在不同编码格式间转换的原理。
788

被折叠的 条评论
为什么被折叠?



