The expandtabs() method in Python String returns a copy of the string where the tab characters ie. '\t' use spaces to expand, making use of the given tabsize (default 8) optionally.
str.expandtabs(tabsize=8)
#!/usr/bin/python str = "this is\tstring example....wow!!!"; print "Original string: " + str print "Defualt exapanded tab: " + str.expandtabs() print "Double exapanded tab: " + str.expandtabs(16)
Original string: this is string example....wow!!! Defualt exapanded tab: this is string example....wow!!! Double exapanded tab: this is string example....wow!!!
Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.