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)
    输出结果为:['张天赐', '小明', '小红', ['刘德华', '谢娜'], '刘飞']
     
  • 相关阅读:
    HEC-ResSim原文档
    水文模型大全
    用word发布博客到博客园
    给你的浏览器标题栏加上小图标
    系统性能调优必知必会学习
    系统性能调优必知必会学习
    容器化学习
    Redisson学习
    mysql回顾
    事物、源码学习,spring-tx
  • 原文地址:https://www.cnblogs.com/ztcbug/p/12056621.html
Copyright © 2011-2022 走看看