Is there a function to remove escape characters from a string ?
jeremiah.dodds at gmail.com
Thu Dec 25 13:35:39 CET 2008
On Thu, Dec 25, 2008 at 7:02 AM, James Stroud <jstroud at mbi.ucla.edu> wrote:
> Stef Mientki wrote:
>> Is there a function to remove escape characters from a string ?
>> (preferable all escape characters except "\n").
test = 'this\r is a test\t yeah\n'
for c in string.printable[-5:]:
if c != '\n':
test = test.replace(c, ' ')
Hmm, should the escape codes be in their own little list in string? Or are
they, and I'm just not seeing them? Is string.printable[-5:] a reliable way
to get the list of escape codes?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list