zoukankan      html  css  js  c++  java
  • 字符串

    test = "alex"

    v = test.capitalize() #首字母大写

    print (v)

    v1 = test.casefold()#所有变有小写

    print(v1)

    v2 = test.lower()

    print(v2)

    v3 = test.center(20,"#)      

    print (v3)  

    结果:########alex########

    test = "alexalexr"

    v4 = test.count('e')

    print (v4)

    结果:2

    v4 = test.count('e',5)

    结果:1

    v5 = test.endswith('ex')

    v6 = test.startswith('ex')

    test = "i am {name},{age}"

    v = test.format(name='alex',age=19)

    test = "i am [0],[1]"

    v = test.format("alex",19")

    test = "uasf890"

    v = test.isalnum()  #只能字母+数字

    test = "12345678 9"

    v = test.expandtable(6)

    结果:12345678    9

    test = "as3df"

    v = test.isalpha()       #是否是字母

    False

    v = test.isdecimal()    是否数字

    v = test.isdigit()          是否数字

    v = test.isnumeric()     是否数字,支持中文

    test = "alex"

    v  = test.swapcase() 大小写转换

    test = "dsklfsdklf dklsfdf"

    v = test.isprintable()  #是否存在不可显示

    False ( , )

    test = " " 

    isspace() 是否全部是空格

    test = " Return is it ..."

    v1 = test.title() 转换为标题

    v2 = test.istitle() 是否为标题

    test = "nishifengerwoshisha"

    print(test)

    t = ' ' 

    v = t.join(test)

    print (v)

    n i s h ...

     v = "_".join(test)

    n_i_....

    test = "alex"

    v = test.ljust(20,"*")

    结果:alex*************...

    v = test.rjust(20,"*")

    *************20

    v = test.zfill(20)

    00000000000000000alex

    test = " alex "

    test.lstrip()  #去左空白

    test.rstrip() #去右

    test.strip()  #去左右

    test.lstrip("al")    #ex

    ------------------------

    必须掌握join,split,find,strip,upper,lower,replace

    --------------------------

    len,for,index,切片

  • 相关阅读:
    彻底弄懂flex布局
    剖析Vue原理&实现双向绑定MVVM
    【Mysql进阶-3】大量实例悟透EXPLAIN与慢查询
    mysql 排序
    从ReentrantLock的实现看AQS的原理及应用
    Java面试之Synchronized解析
    基于vue-cli搭建vue项目开发环境
    在win环境下使用yarn安装 vue-cli
    优化器追踪示例
    MySQL常见的七种锁详细介绍
  • 原文地址:https://www.cnblogs.com/wrw202/p/9533417.html
Copyright © 2011-2022 走看看