python中清空字典

 

1、

>>> a = dict(zip(["one","two","three"],[100,200,300]))
>>> a
{'one': 100, 'two': 200, 'three': 300}
>>> b = a
>>> b
{'one': 100, 'two': 200, 'three': 300}
>>> a = {}
>>> a
{}
>>> b
{'one': 100, 'two': 200, 'three': 300}

 

2、

>>> a = dict(zip(["one","two","three"],[100,200,300]))
>>> a
{'one': 100, 'two': 200, 'three': 300}
>>> b = a
>>> b
{'one': 100, 'two': 200, 'three': 300}
>>> del a
>>> a
Traceback (most recent call last):
  File "<pyshell#1339>", line 1, in <module>
    a
NameError: name 'a' is not defined
>>> b
{'one': 100, 'two': 200, 'three': 300}

 

3、

>>> a = dict(zip(["one","two","three"],[100,200,300]))
>>> a
{'one': 100, 'two': 200, 'three': 300}
>>> b = a
>>> b
{'one': 100, 'two': 200, 'three': 300}
>>> a.clear()
>>> a
{}
>>> b
{}

 

上一篇:crm系统帮助销售人员缩短销售周期


下一篇:three number sum