I have the string
a = 'ddd\ttt\nnn'
a = 'dddtttnnn'
Assuming you want to remove
\n type characters (with those representing
newline in this case and remove the meaning of
\ in the string in general) you can do:
>>> a = 'ddd\ttt\nnn' >>> print a ddd tt nn >>> repr(a)[1:-1].replace('\\','') 'dddtttnnn' >>> print repr(a)[1:-1].replace('\\','') dddtttnnn
If it is a raw string (i.e., the
\ is not interpolated to a single character), you do not need the
>>> a = r'ddd\ttt\nnn' >>> a.replace('\\','') 'dddtttnnn'