for 循环迭代
# -*- coding: utf-8 -*-
words = ['this','is','an','apple']
for word in words :
print word
print
product_list = [
('height',100),
('width',200),
('length',300) ]
for val,data in product_list:
print val,data
运行结果:
this
is
an
apple
height 100
width 200
length 300
for循环应用实例
本文通过两个实例展示了Python中for循环的应用:第一个实例遍历并打印列表中的字符串;第二个实例遍历元组列表,并分别打印每个元素及其对应的数据。
1258

被折叠的 条评论
为什么被折叠?



