python for循环

上例子

字符串

for x in "abcd":
    print x,"hello world"

 

列表

fruits = ['apple','banana','mango']
for index in range(len(fruits)):
    print 'fruit: ',fruits[index]

 

元组

t = (1,2,3,'a','b')
for x in range(len(t)):
    print t[x]

 

 

 

range使用

for n in range(1,11):
    print n,"num"

 

for n in range(1,11,3):
    print n,"num"

  

 

 

 

 

 

 

  

posted on 2017-07-03 15:57  不二家的瓶子  阅读(161)  评论(0编辑  收藏  举报

导航