zoukankan      html  css  js  c++  java
  • 学习Python第四天

    基本数据类型
    数字 int
    字符串 str
    布尔值 bool
    列表 list
    元祖 tuple
    字典 dict
    查看对象的类,或对象所具备的功能
    1、type
    temp = 'a'
    t = type(temp)
    print(t)
    # str,ctr+鼠标左键,找到str类,内部所有的方法
    2、dir
    temp = 'a'
    b= dir(temp)

    3、help,temp
    help(type(temp))
    4、首字母变大写的方法
    a1='aaaa'
    ret = a1.capitalize()
    print(ret)
    5、空白地方填充
    a2='aaa'
    ret1 = a2.center(10,"*")
    print(ret1)
    6、计算单字符在某字符串里出现的次数
    a1='aaaa bbb ccc'
    ret = a1.count('a')
    print(ret)
    7、计算单字符在某字符串里特定位置出现的次数
    a1='aaaa bbb ccc'
    # ret = a1.count('a')
    ret = a1.count('b' ,3,7)
    print(ret)
    8、查看字符串里是否以特定字符结尾(也可以按照特定位置去找)
    temp= 'hello'
    print(temp.endswith('o',0,10))
    9、找到单字符在某字符串里的位置(没找到返回-1)
    a = "hello"
    b = a.find('l')
    print(b)

  • 相关阅读:
    计算机存储单位
    TcpListener、TcpClient
    JobConf
    JobClient
    python正则方法
    c#列表操作
    C#解析xml
    C#字符串操作函数
    Binding
    Name和:Name
  • 原文地址:https://www.cnblogs.com/tornados/p/7902612.html
Copyright © 2011-2022 走看看