zoukankan      html  css  js  c++  java
  • 20181019

    # index = 0
    # while index< len(s):
    # print(s[index])
    # index += 1
    # for 循环 把一个"可迭代对象"中的每一个元素拿出来赋值给前面的"变量"
    '''for 变量in 可迭代对象:
    循环体'''
    # for c in s :
    # print(c)
    # 作业明日默写内容
    # s = ",今天周五了.深圳有什么爱玩的呢? 我爱学习,我爱工作,我爱代码 "
    # for c in s:
    # if c == "爱":
    # break
    # print(c)
    # else:
    # print("收尾")
    # s = input("ABCDabcd深圳爱编程公司")
    # index = 0
    # while index< len(s):
    # print(s[index])
    # index += 1
    # s ="迷途经累劫,悟则刹那间。"
    # index = 0
    # while index< len(s):
    # print(s[index])
    # index += 1
    # s = "迷途经累劫,悟则刹那间"
    # index = 0
    # while index< len(s):
    # print(s[index])
    # index += 1
    # 作业1)移除 name 变量对应的值两边的空格,并输出处理结果
    # name = " aleX leNb "
    # ret = name.strip( )
    # print(ret)
    # 2)移除name变量左边的"al"并输出处理结果
    # name = "aleX leNb"
    # print(name.strip("al"))
    # 3)移除name变量右⾯的"Nb",并输出处理结果#
    # name = "aleX leNb"
    # print(name.strip("Nb"))
    # 4)移除name变量开头的a"与最后的"b",并输出处理结果
    # name = "aleX leNb"
    # print(name.strip("ab"))
    # 5)判断 name 变量是否以 "al" 开头,并输出结果
    # name = "aleX leNb"
    # ret1 = name.startswith("al")
    # print(ret1)
    # 6)判断name变量是否以"Nb"结尾,并输出结果
    # name = "aleX leNb"
    # ret2 = name.endswith("Nb")
    # print(ret2)
    # 7)将 name 变量对应的值中的 所有的"l" 替换为 "p",并输出结果
    # name = "aleX leNb"
    # ret = name.replace('l','p')
    # print(ret)
    # s8 = "sylar_alex_taibai_wusir_eggon"
    # ret = s8.replace('alex','金角大王')
    # print(ret)
    # 8)将name变量对应的值中的第⼀个"l"替换成"p",并输出结果
    # name = "aleX leNb"
    # ret = name.replace('l','p',1)
    # print(ret)
    # 9)将 name 变量对应的值根据 所有的"l" 分割,并输出结果。
    # name = "aleX leNb"
    # lst = name.split("l")
    # print(lst)
    # 10)将name变量对应的值根据第⼀个"l"分割,并输出结果。
    # name = "aleX leNb"
    # lst = name.split("l",1)
    # print(lst)
    # 11)将 name 变量对应的值变⼤写,并输出结果
    # name = "aleX leNb"
    # ret = name.upper()
    # print(ret)
    # 12)将 name 变量对应的值变⼩写,并输出结果
    # name = "aleX leNb"
    # ret = name.lower()
    # print(ret)
    # 13)将name变量对应的值⾸字⺟"a"⼤写,并输出结果
    # name = "aleX leNb"
    # ret = name.capitalize()
    # print(ret) N 变小写了?
    # 14)判断name变量对应的值字⺟"l"出现⼏次,并输出结果
    # name = "aleX leNb"
    # ret = name.count("l")
    # print(ret)
    # 15)如果判断name变量对应的值前四位"l"出现⼏次,并输出结果
    # name = "aleX leNb"
    # ret = name[0:1].count("l")
    # print(ret)
    # 16)从name变量对应的值中找到"N"对应的索引(如果找不到则报错),并输出结果
    # name = "aleX leNb"
    # ret = name.index("N")
    # print(ret)
    # 17)从name变量对应的值中找到"N"对应的索引(如果找不到则返回-1)输出结果
    # name = "aleX leNb"
    # ret = name.find("N")
    # print(ret)
    # 18)从name变量对应的值中找到"X le"对应的索引,并输出结果
    # name = "aleX leNb"
    # ret = name.find("X le")
    # print(ret)
    # 19)请输出 name 变量对应的值的第 2 个字符?
    # name = "aleX leNb"
    # print(name[2])
    # 20)请输出 name 变量对应的值的前 3 个字符?
    # name = "aleX leNb"
    # print(name[:3])
    # 21)请输出 name 变量对应的值的后 2 个字符?
    # name = "aleX leNb"
    # print(name[-2:])
    # 22)请输出 name 变量对应的值中 "e" 所在索引位置?
    # name = "aleX leNb"
    # ret = name.find("e")
    # print(ret)
    # 2.有字符串s = "123a4b5c"
    # 1)通过对s切⽚形成新的字符串s1,s1 = "123"
    # s = "123a4b5c"
    # print(s[:3])
    # 2)通过对s切⽚形成新的字符串s2,s2 = "a4b"
    # s = "123a4b5c"
    # print(s[3:6])
    # 3)通过对s切⽚形成新的字符串s3,s3 = "1345"
    # s = "123a4b5c"
    # print(s[::2])
    # 4)通过对s切⽚形成字符串s4,s4 = "2ab"
    # s = "123a4b5c"
    # print(s[1:6:2])
    # 5)通过对s切⽚形成字符串s5,s5 = "c"
    # s = "123a4b5c"
    # print(s[-1])
    # 6)通过对s切⽚形成字符串s6,s6 = "ba2"
    # s = "123a4b5c"
    # print(s[-3:-8:-2])
    # 3.使⽤while和for循环分别打印字符串s="asdfer"中每个元素。
    # s="asdfer"
    # index = 0
    # while index< len(s):
    # print(s[index])
    # index += 1

    # '''for 循环 把一个"可迭代对象"中的每一个元素拿出来赋值给前面的"变量"
    # '''for 变量in 可迭代对象:
    # 循环体'''
    # for c in s :
    # print(c)
    # s = "asdfer "
    # for c in s:
    # print(c)
    # 4.使⽤for循环对s="asdfer"进⾏循环,但是每次打印的内容都是"asdfer"。
    # s = "asdfer "
    # for i in s:
    # print(s)
    # 5.使⽤for循环对s="abcdefg"进⾏循环,每次打印的内容是每个字符加上sb,例如:asb, bsb,csb,...gsb。
    # s = "asdfer "
    # for i in s:
    # i= i+"sb"
    # print(i)
    # 6.使⽤for循环对s="321"进⾏循环,打印的内容依次是:"倒计时3秒","倒计时2秒","倒计时1秒","出发!"。
    # s = "321"
    # for i in s:
    # i="倒计时{}秒".format(i)
    # print(i )
    # print("出发")
    '''7,实现⼀个整数加法计算器(两个数相加):
    如:content = input("请输⼊内容:") ⽤户输⼊:5+9或5+ 9或5 + 9,然后进
    ⾏分割再进⾏计算。'''
    # content=input("请输入内容:")
    # content = input("请输入数字").strip()
    # s = content.split("+")
    # print(int(s[0])+int(s[0]))
  • 相关阅读:
    grab jpegs from v4l2 devices
    c helloworld on zynq
    minicom installation and configuration on ubuntu
    DBA的做法
    sqlserver锁表、解锁、查看销表
    linux内核分析(网课期末&地面课期中)
    Linux内核分析实验八------理解进程调度时机跟踪分析进程调度与
    LINUX内核分析第七周——可执行程序的装载
    Linux内核分析实验六
    Linux内核分析实验五
  • 原文地址:https://www.cnblogs.com/chenshanqin/p/9819052.html
Copyright © 2011-2022 走看看