How to unescape a raw string?

python at bdurham.com python at bdurham.com
Wed May 19 23:34:13 EDT 2010


How can I unescape a raw string so that it behaves as a non-raw
string?

For example, if I read the string "\n\t A B C\" D E F \xa0
\u1234" from a text file, how can I convert (unescape?) this
string so that \n, \t, \", \x, and \u get converted to a newline,
tab, double quote, hex encoded and unicode encoded chars?

I know I can do this explictly via a series of .replace()
methods, but certainly there must be a built-in way to do this on
a generic basis?

Thank you,
Malcolm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100519/399420a9/attachment.html>


More information about the Python-list mailing list