zoukankan      html  css  js  c++  java
  • pythonDay01

    ---恢复内容开始---

    # 1.center函数空白位置填充。第二个参数可有可无
    # *********V**********
    # *********V**********
    val="V"
    a=val.center(20,"*")
    print(a)
    print(a)
    
    # 2count函数  计算“an”在字符串从哪里开始到哪里结束
    name="lisizhangsan"
    c=name.count("an",0,15)
    print(c)
    
    # startswith 以什么结尾 开始 返回boolean
    name1="zuishiwuqingdiwangjia"
    name1.startswith("zui",0,20)
    name1.endswith("zui",0,20)
    
    #find 函数 返回子集在字符串位置的下表  没有则返回-1 后面区间为前闭后开  index函数找不到直接报错了
    
    test="zhangsan lisu wangwu saner"
    print(test.find("san",1,19))
    
    #format 据我的理解为{}在别的语言代表取变量值 给字符串里面的变量赋值  替换格式化占位符
    test1="i love {name},{age}"
    print(test1.format(name="zhangsan",age=19))
    test1="i love {},{}"
    print(test1.format("zhangsan",19))
    
    #判断字符串是不是包含数字或者字母
    test3="tyssu90"
    print(test3.isalnum())
    
    #for循环进行排序  类似于scala语言
    li = [13, 22, 6, 99, 11]
    
    for m in range(len(li)-1):
    
        for n in range(m+1, len(li)):
            if li[m]> li[n]:
                temp = li[n]
                li[n] = li[m]
                li[m] = temp
    
    print(li)

    ---恢复内容结束---

    # 1.center函数空白位置填充。第二个参数可有可无
    # *********V**********
    # *********V**********
    val="V"
    a=val.center(20,"*")
    print(a)
    print(a)
    
    # 2count函数  计算“an”在字符串从哪里开始到哪里结束
    name="lisizhangsan"
    c=name.count("an",0,15)
    print(c)
    
    # startswith 以什么结尾 开始 返回boolean
    name1="zuishiwuqingdiwangjia"
    name1.startswith("zui",0,20)
    name1.endswith("zui",0,20)
    
    #find 函数 返回子集在字符串位置的下表  没有则返回-1 后面区间为前闭后开  index函数找不到直接报错了
    
    test="zhangsan lisu wangwu saner"
    print(test.find("san",1,19))
    
    #format 据我的理解为{}在别的语言代表取变量值 给字符串里面的变量赋值  替换格式化占位符
    test1="i love {name},{age}"
    print(test1.format(name="zhangsan",age=19))
    test1="i love {},{}"
    print(test1.format("zhangsan",19))
    
    #判断字符串是不是包含数字或者字母
    test3="tyssu90"
    print(test3.isalnum())
    
    #for循环进行排序  类似于scala语言
    li = [13, 22, 6, 99, 11]
    
    for m in range(len(li)-1):
    
        for n in range(m+1, len(li)):
            if li[m]> li[n]:
                temp = li[n]
                li[n] = li[m]
                li[m] = temp
    
    print(li)
  • 相关阅读:
    Delphi通过调用COM对象实现更改桌面壁纸
    Delphi之TDrawGrid绘制
    Delphi中的消息截获(六种方法:Hook,SubClass,Override WndProc,Message Handler,RTTI,Form1.WindowProc:=@myfun)good
    从一般管理原则看微软的重组
    Delphi使用Windows API函数AnimateWindow实现窗体特效
    Delphi下URL汉字编码解码的两个函数
    Delphi2007下CIS的clHttp使用
    Delphi使用XmlHttp获取时间
    提升进程权限为DEBUG权限
    VS 2012 单元测试简单配置
  • 原文地址:https://www.cnblogs.com/hejunhong/p/10316339.html
Copyright © 2011-2022 走看看