zoukankan      html  css  js  c++  java
  • str字符串 expandtabs( ) 方法

    描述

    expandtabs() 方法把字符串中的 tab 符号(' ')转为空格,tab 符号(' ')默认的空格数是 8。

    语法

    expandtabs()方法语法:

    str.expandtabs(tabsize=8)

    参数

    • tabsize -- 指定转换字符串中的 tab 符号(' ')转为空格的字符数。

    返回值

    该方法返回字符串中的 tab 符号(' ')转为空格后生成的新字符串。

    实例

    以下实例展示了expandtabs()方法的实例:

    #!/usr/bin/python3
    
    str = "this is	string example....wow!!!"
    
    print ("原始字符串: " + str)
    print ("替换 \t 符号: " +  str.expandtabs())
    print ("使用16个空格替换 \t 符号: " +  str.expandtabs(16))

    以上实例输出结果如下:

    原始字符串: this is     string example....wow!!!
    替换 	 符号: this is string example....wow!!!
    使用16个空格替换 	 符号: this is         string example....wow!!!
  • 相关阅读:
    Mysql自定义函数总结
    MySQL的基本函数
    Mysql存储过程总结
    Mysql触发器总结
    Mysql索引总结(二)
    Mysql索引总结(一)
    Mysql游标使用
    别人的博客,留待后看
    mysql外键约束总结
    mysql视图总结
  • 原文地址:https://www.cnblogs.com/change06/p/9545936.html
Copyright © 2011-2022 走看看