I thought it would be straight forward to replace a character by a tab. I try the following.
str1 = "a,b,c,d"
str2 = str1.replace(',','\t')
I expect the str2 to be:
a b c d
Instead I get:
a\tb\tc\td
How to replace a charecter with tab?
,
s are indeed being replaced by \t
, but \t
is only "interpreted" when str2
is used as with printing to screen or writing to file:
>>>str1 = "a,b,c,d"
>>>str2 = str1.replace(',','\t')
>>>str2
'a\tb\tc\td'
>>>print str2
a b c d
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With