Python的数据结构 -- 字典

ab = {'001':'李晓诗','002':'胡泽坤','003':'陈春荣','004':'杨松川'}
print('003 is %s' % ab['003'])
for number,name in ab.items():
   print('%s is %s' % (number,name))
ab['005']='灵芝汤'
del ab['002']
if '003' in ab:
   print('003 is %s' % ab['003'])

#通过{}来赋值
#通过del可以删除
#通过in可以遍历
#现在已经没有has_key方法

2015/4/19 by Kerita

原文地址:https://www.cnblogs.com/kerita/p/4447929.html