expandtabs()
my_str.expandtabs(number))
number
: optional , number of space to replace tab character.
By default expandtabs() ads 8 space by replacing all tab characters. We can set the number of spaces by giving input parameter.
my_str='a\tbc\tdef\tghij\tklmno'
my_str=my_str.expandtabs()
print(my_str)
Output
a bc def ghij klmno
my_str='a\tbc\tdef\tghij\tklmno'
my_str=my_str.expandtabs(1)
print(my_str)
Output
a bc def ghij klmno
« All String methods
← Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
https://www.plus2net.com
plus2net.com