Python數組遍歷

直接上代碼:python

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

for colour in colours:
    print colour

# red
# green
# blue

第二種方法blog

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

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

# 0 red
# 1 green
# 2 blue
相關文章
相關標籤/搜索