本文實例講述了Python簡單定義與使用字典的方法。分享給大家供大家參考,具體如下:
#coding=utf8print '''''Python中的字典映射數(shù)據類型是由鍵值對構成。python中字典一般以數(shù)字或者字符串作為鍵。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()運行結果:

更多關于Python相關內容可查看本站專題:《Python字典操作技巧匯總》、《Python字符串操作技巧匯總》、《Python常用遍歷技巧總結》、《Python數(shù)據結構與算法教程》、《Python函數(shù)使用技巧總結》及《Python入門與進階經典教程》
希望本文所述對大家Python程序設計有所幫助。
新聞熱點
疑難解答