Safe string escaping?

Michael Hoffman cam.ac.uk at mh391.invalid
Tue Mar 8 01:36:58 CET 2005


Grant Olson wrote:
> I have a data file that has lines like "foo\n\0" where the \n\0 is acutally
> backslash+n+backslash+0.  I.E. a repr of the string from python would be
> "foo\\n\\0".  I'm trying to convert this string into one that contains
> actual newlines and whatnot.

r"foo\n\0".decode("string_escape")
-- 
Michael Hoffman



More information about the Python-list mailing list