zoukankan      html  css  js  c++  java
  • Python实战之列表list的详细简单练习2

    name_list = ['zhangsan','lisi','wangermazi','xiaotaoqi']
    
    print(name_list)
    
    # name_list.append("william")
    # ['zhangsan', 'lisi', 'wangermazi', 'xiaotaoqi', 'william']
    
    # count = name_list.count('lisi')
    # print("count=",count)
    # count=1
    
    # name_list2 = ['william','alex']
    # name_list.extend(name_list2)
    # ['zhangsan', 'lisi', 'wangermazi', 'xiaotaoqi', 'william', 'alex']
    
    # name_index = name_list.index("xiaotaoqi")
    # print("name_index=",name_index)
    # # name_index= 3
    #
    # name_index = name_list.index("xiaotaoqi1")
    # print("name_index=",name_index)
    # print(name_list)
    #
    # Traceback (most recent call last):
    #   File "C:/Users/Python-learn/list_test.py", line 14, in <module>
    #     name_index = name_list.index("xiaotaoqi1")
    # ValueError: 'xiaotaoqi1' is not in list
    
    # name_list.insert(2,"William")
    # ['zhangsan', 'lisi', 'William', 'wangermazi', 'xiaotaoqi']
    
    # name_list.pop()
    # ['zhangsan', 'lisi', 'wangermazi']
    # name_list.pop(2)
    # ['zhangsan', 'lisi', 'xiaotaoqi']
    
    # name_list.remove("lisi")
    # ['zhangsan', 'wangermazi', 'xiaotaoqi']
    
    # name_list.reverse()
    # ['xiaotaoqi', 'wangermazi', 'lisi', 'zhangsan']
    
    num_list = [1,3,6,1,2,9,4,5,3]
    
    
    # print(name_list.__add__(num_list))
    # ['zhangsan', 'lisi', 'wangermazi', 'xiaotaoqi', 1, 3, 6, 1, 2, 9, 4, 5, 3]
    
    print(name_list.__contains__("lisi"))
    # True
    
    # print(name_list.__delitem__(2))
    # ['zhangsan', 'lisi', 'xiaotaoqi']
    
    print(name_list.__de)
    print(name_list)
  • 相关阅读:
    CF1119H
    oracle 第06章 数据字典
    oracle col命令
    oracle 第05章 SQL语句
    oracle 第04章 字符集
    oracle 第03章 体系结构
    oracle 第02章 基本操作
    oracle 第01章 安装
    oracle启动、关闭、重启脚本
    第十一周-学习进度条
  • 原文地址:https://www.cnblogs.com/william126/p/7099790.html
Copyright © 2011-2022 走看看