标签:range 深拷贝 orm int print mem form nbsp 拷贝
m=2
n=3
memo_01 = [[1] * m for i in range(n) ]
memo_02 = [[1]*m]*n
print("memo_01:{},memo_02:{},".format(memo_01,memo_02)) # memo_01:[[1, 1], [1, 1], [1, 1]],memo_02:[[1, 1], [1, 1], [1, 1]]
memo_01[0][0]=2 # 这一种创建方式类似于深拷贝
memo_02[0][0]=2 # 这一种创建方式类似浅拷贝
print("memo_01:{},memo_02:{},".format(memo_01,memo_02)) # memo_01:[[2, 1], [1, 1], [1, 1]],memo_02:[[2, 1], [2, 1], [2, 1]]
标签:range 深拷贝 orm int print mem form nbsp 拷贝
原文地址:https://www.cnblogs.com/wenshu/p/12303930.html