Python String expandtabs() Method

Replaces tab characters in a string with the specified number of whitespaces.

Syntax

Python
string.expandtabs(tabsize = 8)

Parameters

ParameterDescription
tabsize Optional. The tab size in spaces. The default is 8

Example

Python
print('a\tb\tc'.expandtabs(20))

Output

a                    b                    c