码迷,mamicode.com
首页 > 编程语言 > 详细

Python数组遍历

时间:2015-09-24 12:37:33      阅读:239      评论:0      收藏:0      [点我收藏+]

标签:

直接上代码:

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

  

Python数组遍历

标签:

原文地址:http://www.cnblogs.com/CodeTracker/p/4834676.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!