Escape chars in string

Jeff Epler jepler at
Mon Nov 8 21:44:07 CET 2004

Python 2.3 has a 'string-escape' codec.  If you have a string like '\\t'
(a literal backslash followed by a t) and want to turn it into the
string '\t' (a tab character), you can use it for that purpose:
    >>> r"a\tb".decode("string-escape")

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <>

More information about the Python-list mailing list