Safe string escaping?

Daniel Bickett dbickett at gmail.com
Mon Mar 7 19:42:03 EST 2005


There is very likely a more reasonable solution than this, but it was
the first one that came to mind:

IDLE 1.0.3      
>>> string = "foo\\n\\0"
>>> string = string.replace( "\\n" , "\n" )
>>> string = string.replace( "\\0" , "\0" )
>>> string
'foo\n\x00'
>>> print string
foo


Hope this helps.

-- 
Daniel Bickett
dbickett at gmail.com
http://heureusement.org/



More information about the Python-list mailing list