如何在Python3中进行.decode('string-escape')?

如何在Python3中进行.decode('string-escape')?,第1张

如何在Python3中进行.decode('string-escape')?

如果您希望 海峡 至- 海峡 转义序列的解码,所以输入和输出都是Unipre:

def string_escape(s, encoding='utf-8'):    return (s.enpre('latin1')         # To bytes, required by 'unipre-escape'  .depre('unipre-escape') # Perform the actual octal-escaping depre  .enpre('latin1')         # 1:1 mapping back to bytes  .depre(encoding))        # Depre original encoding

测试:

>>> string_escape('3omething special')'Something special'>>> string_escape(r's00u00p00p00o00r00t00@'       r'00p00s00i00l00o00c00.00c00o00m00',       'utf-16-le')'support@psiloc.com'


欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/zaji/5508052.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-13
下一篇2022-12-13

发表评论

登录后才能评论

评论列表(0条)

    保存