Python字符串方法expandtabs()返回其中包含制表符ie的字符串副本。‘使用空格展开,也可以使用给定的制表符大小(默认值为8).
str.expandtabs(tabsize=8)
tabsize - 这指定要替换制表符的字符数。
#!/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!!!
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)