本文实例讲述了Python简单定义与使用字典的方法。分享给大家供大家参考,具体如下:
#coding=utf8
print '''''
Python中的字典映射数据类型是由键值对构成。
python中字典一般以数字或者字符串作为键。
Python中字典的值可以是任意类型的Python对象,字典元素用大括号{}包裹。
'''
dicDefine={
 'Name':'ewang',
 'Age': 28,
 'Sex': 'famale',
 'BirthDay':'1998/09/1'
 }
print 'The content of dicDefind',dicDefine
print 'The keys of dicDefind',dicDefine.keys( )
print 'The values of dicDefind',dicDefine.values()
print 'The items of dicDefind',dicDefine.items()
运行结果:
