亚洲熟女综合色一区二区三区,亚洲精品中文字幕无码蜜桃,亚洲va欧美va日韩va成人网,亚洲av无码国产一区二区三区,亚洲精品无码久久久久久久

【Python面試真題】- 對(duì)比一下dict中items與iteritems?

 D = {'a':1,'b':2,'c':3,'d':4}    
 D.items()                       #一次性取出所有    
[('a', 1), ('c', 3), ('b', 2), ('d', 4)]    
 D.iteritems()                   #迭代對(duì)象,每次取出一個(gè)。用for循環(huán)遍歷出來;    
    
 for i in D.iteritems():    
…   print i,    
…    
('a', 1) ('c', 3) ('b', 2) ('d', 4)    
 for k,v in D.iteritems():    
…   print k,    
…    
a c b d    
總結(jié):   
1. 一般iteritems()迭代的辦法比items()要快,特別是數(shù)據(jù)庫(kù)比較大時(shí)。  

2. 在Python3中一般取消前者函數(shù)  



相關(guān)新聞

歷經(jīng)多年發(fā)展,已成為國(guó)內(nèi)好評(píng)如潮的Linux云計(jì)算運(yùn)維、SRE、Devops、網(wǎng)絡(luò)安全、云原生、Go、Python開發(fā)專業(yè)人才培訓(xùn)機(jī)構(gòu)!