本文實(shí)例講述了Python簡(jiǎn)單定義與使用字典的方法。分享給大家供大家參考,具體如下:
#coding=utf8print '''''Python中的字典映射數(shù)據(jù)類(lèi)型是由鍵值對(duì)構(gòu)成。python中字典一般以數(shù)字或者字符串作為鍵。Python中字典的值可以是任意類(lèi)型的Python對(duì)象,字典元素用大括號(hào){}包裹。'''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()運(yùn)行結(jié)果:

希望本文所述對(duì)大家Python程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注