Backslash substitutions

Peter Otten __peter__ at web.de
Wed Sep 29 15:24:39 EDT 2004


Vivien Mallet wrote:

> How would you perform backslash substitution in a string, just like the
> Python parser does?

 >>> "\\\\A\\tB".decode("string_escape")
'\\A\tB'
>>> _.encode("string_escape") # back again
'\\\\A\\tB'

Peter




More information about the Python-list mailing list