目录

expandtabs(tabsize=8)

描述 (Description)

它返回字符串的副本,其中包含制表符。 使用空格扩展'\ t',可选择使用给定的制表符(默认为8)。

语法 (Syntax)

str.expandtabs(tabsize=8)

参数 (Parameters)

  • tabsize - 指定要为制表符'\ t'替换的字符数。

  • 回报价值

  • 此方法返回字符串的副本,其中使用空格展开制表符,即'\ t'。

例子 (Example)

#!/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)

结果 (Result)

Original string: this is        string example....wow!!!
Defualt exapanded tab: this is string example....wow!!!
Double exapanded tab: this is         string example....wow!!!
↑回到顶部↑
WIKI教程 @2018