Safe string escaping?

Daniel Bickett dbickett at gmail.com
Tue Mar 8 01:42:03 CET 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