标签:style for循环 div banner str 语句 current family strong
#if-else if a > b: print(‘aaa‘) else: print(‘bbb‘) #if-elif-else if a > b: print(‘a>b‘) elif a == b: print(‘a==b‘) else: print(‘a<b‘)
while 判断条件: 执行语句
for temp in sequence: 执行语句
#-*- coding:utf-8 -*- for letter in ‘python‘:
print(‘current letter is %s‘%letter)
#-*- coding:utf-8 -*- fruits = [‘banner‘,‘apple‘,‘orange‘] for fruit in fruits: print(‘current fruit is %s‘%fruit)
Python中for else 语句 只要for循环语句不是通过break结束循环,那么无论for循环有没有执行,都会执行else里的语句. while ...else也是一样
break:跳出整个循环
continue:跳出本次循环,继续执行下一次循环
标签:style for循环 div banner str 语句 current family strong
原文地址:http://www.cnblogs.com/wgDream/p/6679635.html