PHP前端开发

Python中关于字典dict的使用详解

百变鹏仔 2小时前 #Python
文章标签 字典

这篇文章主要介绍了python简单定义与使用字典的方法,结合简单实例形式分析了python字典的原理、组成、定义及使用方法,需要的朋友可以参考下

本文实例讲述了Python简单定义与使用字典的方法。分享给大家供大家参考,具体如下:


#coding=utf8print '''''Python中的字典映射数据类型是由键值对构成。python中字典一般以数字或者字符串作为键。Python中字典的值可以是任意类型的Python对象,字典元素用大括号{}包裹。'''dicDefine={  'Name':'ewang',  'Age': 28,  'Sex': 'famale',  'BirthDay':'1998/09/1'  }print 'The content of dicDefind',dicDefineprint 'The keys of dicDefind',dicDefine.keys( )print 'The values of dicDefind',dicDefine.values()print 'The items of dicDefind',dicDefine.items()

运行结果: