Clear (), clear
Note that the simple assignment is equivalent to the C language Reference, only an extra alias, so they point to the same address,
So c={}, just another open up a new space to let C is empty, and did not change the space before, so {} and clear () look at the same function, in fact, the principle of implementation is not the same
650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" Margin:0px;padding:0px;border:none; "/>
>>> di{1:11, 2:22, 3:33}>>> di.clear () >>> di{}>>> >>> >>> a={1:1 1}>>> b=a>>> c=a>>> a{1:11}>>> b{1:11}>>> c{1:11}>>> c={}>& Gt;> a{1:11}>>> b{1:11}\\>>> a.clear () >>> a{}>>> b{}>>>
650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" Margin:0px;padding:0px;border:none; "/>
650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" Margin:0px;padding:0px;border:none; "/>
1 >>> aa={1:11} 2 >>> a 3 {} 4 >>> b=a.copy () #浅拷贝 5 >>> c=a 6 >>> ID (a) 7 490 87896L 8 >>> ID (b) 9 49087624l10 >>> ID (c) 49087896l12 >>>
650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" Margin:0px;padding:0px;border:none; "/>
The question of the above-mentioned shallow copy
Pop () deletes the specified
Popitem Random Deletion
Update updates
650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" Margin:0px;padding:0px;border:none; "/>
1 >> 2 >>> index1={1:11,2:22,3:33} 3 >>> Index1.pop (2) 4 22 5 >>> index1 6 {1: 11, 3: 33} 7 >>> index1.popitem () 8 (1, 11) 9 >>> Index110 {3: 33}11 >>> index1.setdefault (4) 12 >>> index113 {3: 33, 4: none}14 >>> index1.setdefault (5,55) 15 5516 > >> INDEX117 {3: 33, 4: NONE, 5: 55}18 >>> B={4:44} 19 >>> a.update (b) 20 >>> a21 {4: 44}22 >>> Index1.update (b) 23 >>> index124 {3: 33, 4: 44, 5: 55}25 >>>
650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" Margin:0px;padding:0px;border:none; "/>
Functions of the Python dictionary