Translating escaped characters

Henrik S. Hansen hsh at
Tue Nov 2 08:12:08 CET 2004

Steven Bethard <steven.bethard 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'
>>>> '\n'.encode('string_escape')
> '\\n'

Precisely, thank you.

Henrik S. Hansen
Computer science (software engineering) student
Free Software Foundation member #1702 (

More information about the Python-list mailing list