python dict 遍历

refer to:

https://blog.csdn.net/CuGBabyBeaR/article/details/25037687

https://blog.csdn.net/Jarry_cm/article/details/99684387

 

四种方式, 1, 3最快 

 

1)

for i in d:

  t = i + d[i]

 

2)

for k,v in d.items():

  t = k + v

 

3)

for k,v in d.iteritems():

  t = k + v

 

4)

for k,v in zip(d.iterkeys(),d.itervalues()):

  t = k + v

 

posted @ 2020-11-04 17:11  清源居士  阅读(1820)  评论(0编辑  收藏  举报