dic = { 'name' : 'niuli' , 'age' : ' 23' }
方法1: 慢速 会把字典转换为列表再循环
for k , v in dic.items():
print(k,v)
方法2:快速
for k in dic :
print( k , dic[ k ] )
dic = { 'name' : 'niuli' , 'age' : ' 23' }
方法1: 慢速 会把字典转换为列表再循环
for k , v in dic.items():
print(k,v)
方法2:快速
for k in dic :
print( k , dic[ k ] )
本文标题:字典循环两种方法比较
本文链接:https://www.haomeiwen.com/subject/mtudhftx.html
网友评论