天天看點

5.3 for循環

for 循環主要用來周遊清單、字元串、檔案等進行操作,預設是循環到最後一個元素為止。

test=dict(a=1,b=2,c=3,d=4)

for i,j in test.items():

   print(i,j)

傳回結果:

a 1

b 2

c 3

d 4

 本文轉自 歸來仍少年 51CTO部落格,原文連結:http://blog.51cto.com/shaoniana/1976261

繼續閱讀