foræ§æ(ç¹°ãè¿ãï¼)
â¼æ¸å¼
for å¤æ° in ã·ã¼ã±ã³ã¹: æï¼ else: æï¼
ã·ã¼ã±ã³ã¹(æååããªã¹ããã¿ãã«ãè¾æ¸ãªã©)ã®å¤ãå¤æ°ã«ä»£å
¥ããªããé 次ãæï¼ãå®è¡ã
ã·ã¼ã±ã³ã¹ãåããã£ããelseãããã¯ã®æï¼ãå®è¡
â¼ä½¿ãæ¹
for count in [0, 1, 2, 3, 4]: print count, "åç®" else: print "End"
â¼å®è¡çµæ
0 åç® 1 åç® 2 åç® 3 åç® 4 åç® End
â¼ãããã使ãæ¹
æå®åæ°ç¹°ãè¿ãããã¨ãã¯range()ã使ã
>>> ========================= RESTART ========================= >>> for count in range(10): print count 0 1 2 3 4 5 6 7 8 9 >>>
åè:4.2 for æ
http://www.python.jp/doc/release/tut/node6.html#SECTION006200000000000000000