zoukankan      html  css  js  c++  java
  • 基本数据类型常用功能:


    1.整数 int
       a. 
        n1= 123
        n2 =456
        (n1+n2)


        print(n1.__add__(n2))
      b.
     获取可表示的二进制最短位数
      n1 = 4  #00000100
      ret = n1.bet_length()
      print(ret)

    2.字符串
    a1= "alex"
    ret =a1.capitalize()  #首字母大写
    print(ret)
    ret =a1.center(20,'*') #居中,长度20
    print(ret)
    a1 = "alex is alph"
    ret=a1.count("a",0,10)  #从0到第10个子串出现的次数
    print(ret)
    temp = "hello"
    print(temp.endswith('o')) #是否是以o结尾的
    content = "hello 999"
    print(content.expandtabs()) #将tab换成空格
    print(content.expandtabs(20))
    s = "alex hello "
    print(s.find("ex")) #返回找到的子串的位置,没找到返回-1

    s= "hello {0},age {1}"
    print(s)
    #{0占位符}
    new1= s.format('alex',19) #格式化,0.1都是占位符
    print(new1)
    #jion
    li = ["alex","eric"] #列表类型
    s="_".join(li)  #用_链接字符串
    print(s)

  • 相关阅读:
    JvisualVM、JMC监控远程服务器
    MVC学习笔记3
    MVC学习笔记2
    菜鸟级appium 必看
    关于redis一些问题记录
    git和github的区别
    VMware快照
    LR创建数据源读取excel
    mysql 5.7.18 源码安装笔记
    IDEA 配置Junit4
  • 原文地址:https://www.cnblogs.com/wuguobiao/p/7461982.html
Copyright © 2011-2022 走看看