How to replace tabs in a row?

I need to replace tabs in a string, but only tabs, not spaces.

If I use the str.replace () function, what will be in the first set of quotes?

+10
source share
2 answers

In python string literals, the pair '\ t' represents a tab character. So you would use mystring.replace('\t', 'any other string that you want to replace the tab with').

+9
source
str.replace("\t", "TAB_WAS_HERE")
+8
source

All Articles