1 如果字典里一个键指向一个实例,深拷贝会拷贝出一个新的实例吗?
不会:
class foo:
def __init__(self):
print('do init foo')
a = {'cls': foo()}
a
# -------------------
do init foo
{'cls': <__main__.foo at 0x7fd18a246590>}
# -------------------
import copy;
b = copy.deepcopy(a)
# -------------------
b
{'cls': <__main__.foo at 0x7fd18a247a50>}
标签:__,疑难问题,Python,-------------------,init,整理,foo,cls
From: https://www.cnblogs.com/jneeee/p/pythontricks.html