我有一些转义字符串需要取消转义.我想用Python来做这个.
例如,在Python 2.7中,我可以这样做:
>>> "\\123omething special".decode('string-escape')
'Something special'
>>>
在Python3中如何实现?这不管用:
>>> b"\\123omething special".decode('string-escape')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
LookupError: unknown encoding: string-escape
>>>
我的目标是能够像这样拿起一根绳子:
s\000u\000p\000p\000o\000r\000t\000@\000p\000s\000i\000l\000o\000c\000.\000c\000o\000m\000
把它变成:
"support@psiloc.com"
完成转换后,我将探索我拥有的字符串是用UTF-8还是UTF-16编码的.