• day02_02 列表切割


    # Author:Adminone
    
    import copy
    
    #names = "ZhangYang Guyun Xiangpeng XuLiangChen"
    names = ["ZhangYang", "Guyun","XiangPeng","XuLiangchen"]
    #names = ["4ZhangYang", "Guyun","XiangPeng",["alex","jack"],"ChenRonghua","XuLiangchen"]
    
    '''
    print("list-1",names)
    print("list-2",names[0],names[2])
    print("list-3",names[1:3])   #<==左闭右开,切片
    print("list-4",names[-3:-1]) #<==左闭右开,切片
    print("list-5",names[-2:])
    '''
    
    '''
    #循环,步长
    #print(names[0:-1:2])
    #print(names[::2])
    #print(names[:])
    #range(1,10,2)
    
    for i in names:
        print(i)
    
    name2 = copy.deepcopy(names)
    print(names)
    print(name2)
    names[2] = "向鹏"
    names[3][0] ="ALEXANDER"
    
    print(names)
    print(name2)
    names.append("LeiHaidong")
    names.insert(1,"ChenRonghua")
    names.insert(3,"Xinzhiyu")
    #names[2] ="XieDi"
    
    #print(names[0],names[2])
    #print(names[1:3]) #切片
    #print(names[3]) #切片
    #print(names[-2:]) #切片
    #print(names[0:3]) #切片
    #print(names[:3]) #切片
    
    #delete
    #names.remove("ChenRonghua")
    #del names[1] =names.pop(1)
    #names.pop(1)
    print(names)
    #根据下标取值
    #print(names.index("XieDi"))    #<==下标查询
    #print(   names[names.index("XieDi")]   )
    
    #成员计数
    print(names.count("ChenRonghua"))
    #names.clear()
    #反转
    names.reverse()
    #按ASCII排序
    names.sort()
    
    print(names)
    names2 = [1,2,3,4]
    #names 扩展
    names.extend(names2)
    
    #del names2
    print(names,names2)
    '''
    ''' 
    a  =[1,2,3]
    b = a
    a[1] =555
    b = [1,555,3]
    
  • 相关阅读:
    Dao跨事务调用实现转账功能
    QueryRunner类 的應用,以及ResultSetHandler 接口的实现类
    C3P0数据源的使用
    iOS中UI阶段常用的一些方法
    谷歌云服务器的使用
    Odoo学习之domain表达式【转载】
    odoo 视图继承
    Odoo字段类型详解
    odoo12:命令行
    xpath转义‘
  • 原文地址:https://www.cnblogs.com/netflix/p/14854063.html
Copyright © 2020-2023  润新知