Translating escaped characters

Steven Bethard steven.bethard at
Mon Nov 1 23:59:48 CET 2004

Henrik S. Hansen <hsh <at>> writes:

> How do you best go about translating characters like '\\n' to '\n'?

Is this what you're looking for?

>>> '\\n'.decode('string_escape')
>>> '\n'.encode('string_escape')

There's some info about it here:

and searching Google Groups shows up a few things too:

(Sorry, the URL wrapped.)


More information about the Python-list mailing list