在本教程中,我们将向您展示如何使用for-in-loop
在Python中循环一个List。
#example 1
frameworks = ['flask', 'pyramid', 'django'] #list
for temp in frameworks:
print temp
print "Python framework : %s" %temp
#example 2
numbers = [2,4,6,8,10] #list
for num in numbers:
print num
print "Number : %d" %num
输出量
flask
Python framework : flask
pyramid
Python framework : pyramid
django
Python framework : django
2
Number : 2
4
Number : 4
6
Number : 6
8
Number : 8
10
Number : 10