zoukankan      html  css  js  c++  java
  • list方法补充

    在上一个随便我们写了list 常用的方法,该随便为一些需要补充的内容

    注:本次例子为:

    student = ["张天赐","小明","小红",[“张杰”,"谢娜"],"刘飞"]
    number = [1,2,3,9,5,6]
    ------------------------------------------------------------------------------分割线,以上为例子,以下为方法
    1.copy使用方法:把A列表下内容复制到B列表下(浅copy,copy内存地址,非值,被copy者发生变化,copy后的也会跟着变化)  (deep为深copy)
     
    number2 = number.copy() 
    print(number)
    print(number2)
    输出结果:

    [1, 2, 3, 9, 5, 6]
    [1, 2, 3, 9, 5, 6]

    2.student[n] = "哈哈哈":将任意下标的值改为任意内容

    注:下标从0开始,student下标为0 = “张天赐”  以此类推

    student[0] = "周润发"
    print(student)
     
    输出结果为:['周润发', '小明', '小红', '刘飞']
     
    3.student[n][n] = “n”  :修改列表中包含的列表字段
    student[3][0] = "刘德华"
    print(student)
    输出结果为:['张天赐', '小明', '小红', ['刘德华', '谢娜'], '刘飞']
     
  • 相关阅读:
    tar压缩
    sh脚本的dos和unix
    hive常用函数
    hive的union问题
    hive行转多列LATERAL VIEW explode
    Iterator和Enumeration
    基础啊基础
    一道考题---当n=1,2,3...2015时,统计3n+n3能整除7的个数
    自然语言处理
    矩阵相乘
  • 原文地址:https://www.cnblogs.com/ztcbug/p/12056621.html
Copyright © 2011-2022 走看看