How to unescape a raw string?
python at bdurham.com
python at bdurham.com
Thu May 20 00:13:28 EDT 2010
Hi Chris,
> That's not what the notion of raw strings in Python technically means, but anyway...
Agree - I was having a difficult time trying to describe my dilemma -
thanks for hanging in there with my rather awkward intro :)
> I'll assume you're quoting the file contents itself verbatim here, rather than a Python string literal (which would require doubling up
on the backslashes).
Yes.
> new_string = your_string.decode('string_escape')
That's just the clue I needed. The actual decoder I needed turned out to
be 'unicode_escape' because of my embedded \uxxxx markup.
new_string = your_string.decode('unicode_escape')
Thank you for your help Chris!
Regards,
Malcolm
More information about the Python-list
mailing list