zoukankan      html  css  js  c++  java
  • 6.in深浅拷贝图示

    深浅拷贝

    import copy
    
    lis1 = [1,2,[1,2,3]]
    lis2 = lis1
    lis3 = copy.copy(lis1)
    lis4 = copy.deepcopy(lis1)
    
    print(id(lis1))
    print(id(lis2))
    print(id(lis3))
    print(id(lis4))
    print('-'*60)
    
    print(id(lis1[0]))
    print(id(lis2[0]))
    print(id(lis3[0]))
    print(id(lis4[0]))
    print('-'*60)
    
    print(id(lis1[1]))
    print(id(lis2[1]))
    print(id(lis3[1]))
    print(id(lis4[1]))
    print('-'*60)
    
    print(id(lis1[2]))
    print(id(lis2[2]))
    print(id(lis3[2]))
    print(id(lis4[2]))
    print('-'*60)
    
    print(id(lis1[2][0]))
    print(id(lis2[2][0]))
    print(id(lis3[2][0]))
    print(id(lis4[2][0]))
    print('-'*60)
    
    print(id(lis1[2][1]))
    print(id(lis2[2][1]))
    print(id(lis3[2][1]))
    print(id(lis4[2][1]))
    print('-'*60)
    
    print(id(lis1[2][2]))
    print(id(lis2[2][2]))
    print(id(lis3[2][2]))
    print(id(lis4[2][2]))
    
    15877384
    15877384
    15879424
    52865224
    ------------------------------------------------------------
    1467140224
    1467140224
    1467140224
    1467140224
    ------------------------------------------------------------
    1467140240
    1467140240
    1467140240
    1467140240
    ------------------------------------------------------------
    15949992
    15949992
    15949992
    52865424
    ------------------------------------------------------------
    1467140224
    1467140224
    1467140224
    1467140224
    ------------------------------------------------------------
    1467140240
    1467140240
    1467140240
    1467140240
    ------------------------------------------------------------
    1467140256
    1467140256
    1467140256
    1467140256
    
    
    
  • 相关阅读:
    FMDB增删查改
    https相关内容
    支付宝、微信支付参考博客
    下标脚本(Swift)
    函数(swift)
    控制流(swift)
    UIView Methods
    oc js 交互
    我和Lua并非一见钟情,我们期待着日久生情(相遇篇)
    与Python Falling In Love_Python跨台阶(面向对象)
  • 原文地址:https://www.cnblogs.com/yellowcloud/p/10839125.html
Copyright © 2011-2022 走看看