Python数组遍历

直接上代码:

colours = ["red","green","blue"]

for colour in colours:
    print colour

# red
# green
# blue

第二种方法

colours = ["red","green","blue"]

for i in range(0, len(colours)):
    print i, colour[i]

# 0 red
# 1 green
# 2 blue

  

posted @ 2015-09-24 11:11  CodeTracker  阅读(417)  评论(0编辑  收藏  举报