Reputation: 1941
I have unicode-like strings but with slash escaped. For example, '\\u000D'
. I need to decode them as normal strings. The above example should be convert to '\r'
which '\u000D'
corresponds to.
Upvotes: 6
Views: 1432
Reputation: 90995
Use the unicode-escape
codec.
>>> import codecs
>>> codecs.decode('\\u000D', 'unicode-escape')
'\r'
Upvotes: 11