处理列表中的每一项是一个非常常见的需求,如何在python中快速的处理列表的迭代呢?
movies=["The Holy Grail",1975,"The Life of Brian",1979,"The Meaning of Life",1983]
for each_item in movies:
print(each_item)
语法如下
for 目标标识符 in 列表
列表处理代码
还有一种候选写法,用while写
count=0
while count<len(movies):
print(movies[count])
count=count+1
基本上都是选择for循环
网友评论