1.clear
dict.clear()
2.copy
a,b用的字典引用位置是相同的,a or b相互受对方影响
所以有时候需要用到copy and deepcopy函数
a = b = dict 1>
b = a.copy()
发生替换双方值不换相互影响,涉及新增 删除会相互影响
2>deepcopy
from copy import deepcopy
b = deepcopy(a)
3.get
dict.get('key',' ')
4.has_key() 注:python3.0已经没有该函数
dict.has_key('key')
5.items and iteritems
dict.items()
for k,v in dict.items():
print k
print v
for k,v in list(dict.iteritems()):
print k
print v
6.keys and iterkeys
for k in dict.keys():
print k
for k in list(dict.iterkeys()):
print k
7.values and itervalues
for v in dict.values():
print v
for v in list(dict.itervalues()):
print v
8.pop
移除字典当中键和值
dict = {'name':'az','age':'18'}
dict.pop('name')
dict = {'age':'18'}
9.update
存在就更新,不存在就加入
dict.update(dict2)