Escaping certain characters

Robert Kern rkern at ucsd.edu
Sun Jul 31 06:30:56 EDT 2005


Jan Danielsson wrote:
> Jan Danielsson wrote:
> 
>>>In [3]: s.encode('string_escape')
>>>Out[3]: 'Hello\\nWorld!'
>>>
>>>In [4]: Out[3].decode('string_escape')
>>>Out[4]: 'Hello\nWorld!'
>>>
>>>Not *quite* what you asked for, but it ought to be close enough.
>>
>>That'll do just fine. Many thanks!
> 
> Hmm... On second thought, I need to escape more characters.
> 
> Is there no other way to escape characters in strings?

Which characters?

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter




More information about the Python-list mailing list