# -*- coding:UTF-8 -*-
'''
Created on 2015年10月25日
@author: young
'''
dic={'a':123,'b':456}
dic[789]='c'
print dic
print dic.items()
for ele in dic: #for循环得到的是键
print ele,'=', dic[ele]
print dic.pop('a')
print dic
print dic.keys()
print dic.values()
dic.update( {'b':999} )
print dic
print dic.get('b')
print dic.has_key('b')
dic.clear()
print dic
打印如下
{'a': 123, 'b': 456, 789: 'c'}
[('a', 123), ('b', 456), (789, 'c')]
a = 123
b = 456
789 = c
123
{'b': 456, 789: 'c'}
['b', 789]
[456, 'c']
{'b': 999, 789: 'c'}
999
True
{}