“copy” 与 “=“赋值

前拷贝  与  赋值

>>> a = {1:'one',2:'two',3:'three'}
>>> b = a.copy()
>>> c = a
>>> id(a)
2217313747232
>>> id(b)
2217313747304
>>> id(c)
2217313747232

赋值贴一个新标签在相同数据上

>>> c[4] = 'four'
>>> c
{1: 'one', 2: 'two', 3: 'three', 4: 'four'}
>>> a
{1: 'one', 2: 'two', 3: 'three', 4: 'four'}
>>> b
{1: 'one', 2: 'two', 3: 'three'}

posted @ 2018-03-11 22:46  我们分头打钱!  阅读(105)  评论(0编辑  收藏  举报