Skip to content
String Methods

expandtabs()

Replace tab characters with spaces up to the next tab stop.

str.expandtabs(tabsize=8)

Replace tab characters with spaces up to the next tab stop.

Parameters

NameDescription
tabsizeThe number of spaces between tab stops.

Returns

A new string with tabs expanded.

Try it

Run it and change it
text = "a\tb"
print(text.expandtabs(4))

Related entries