Python expandtabs () method
description
Python expandtabs () method to string tab symbol ( '\ t') into space, tab symbol ( '\ t') is the default number of spaces 8.
grammar
expandtabs () method syntax:
str.expandtabs(tabsize=8)
parameter
- tabsize - specify the conversion string tab symbol ( '\ t') into space characters.
return value
The new string generation method returns a string tab symbol ( '\ t') into space after.
Examples
The following example shows an example of expandtabs () method:
#!/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);
Examples of the above output results are as follows:
Original string: this is string example....wow!!! Defualt exapanded tab: this is string example....wow!!! Double exapanded tab: this is string example....wow!!!