Python3 expandtabs () method
description
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/python3 str = "this is\tstring example....wow!!!" print ("原始字符串: " + str) print ("替换 \\t 符号: " + str.expandtabs()) print ("使用16个空格替换 \\t 符号: " + str.expandtabs(16))
Examples of the above output results are as follows:
原始字符串: this is string example....wow!!! 替换 \t 符号: this is string example....wow!!! 使用16个空格替换 \t 符号: this is string example....wow!!!