From 849135f2eb123d4430ffd78f7cdd566310252ba4 Mon Sep 17 00:00:00 2001 From: xuma Date: Sun, 21 Aug 2022 15:46:00 +0800 Subject: [PATCH] =?UTF-8?q?2022/08/21=20=E5=91=A8=E6=97=A5=2015:46:00.12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/_posts/踩坑日记.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/source/_posts/踩坑日记.md b/source/_posts/踩坑日记.md index 7b5a0b76..c78f9088 100644 --- a/source/_posts/踩坑日记.md +++ b/source/_posts/踩坑日记.md @@ -33,4 +33,33 @@ aside: 原因: 这是因为numpy版本不对。 cvxopt使用了MKL,所以应该使用链接到英特尔数学库的版本:Numpy+MKL 其在Numpy中包含所需的dll。 +### 3, python的list.append(anotherList)中, anotherList会被连续更新的问题 + +这是一个深浅拷贝问题 + +```python +print("============浅拷贝========") +a = [1] +b = ['b'] +b.append(a) +print('a: ', a) +print('b: ', b) + +a.append(2) +print('a.append(2)后的a: ', a) +print('a.append(2)后的b: ', b) +print() + +print("===========深拷贝========") +c = ['c'] +c.append(a.copy()) +print('a: ', a) +print('c: ', c) + +a.append(3) +print('a.append(3)后的a: ', a) +print('a.append(3)后的c: ', c) + +``` + >未完待续