Fork me on GitHub

Python浅拷贝与深拷贝

我们知道,在Python内部有浅拷贝与深拷贝之分。但长久以来,有一个问题一直困扰着我,类似dict.copy()这种方式到底是浅拷贝还是深拷贝?原来,Python的官方文档Shallow and deep copy operations早就给出了答案。

Shallow copies of dictionaries can be made using dict.copy(), and of lists by assigning a slice of the entire list, for example, copied_list = original_list[:].

梦想还是要有的,万一有人赏了呢