Safe string escaping?

Michael Hoffman cam.ac.uk at mh391.invalid
Mon Mar 7 19:36:58 EST 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