
如果您希望 海峡 至- 海峡 转义序列的解码,所以输入和输出都是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'欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)