Python 循环控制:break、continue、pass
break: 跳出 整个 for 循环
continue: 跳出 此次 循环
pass: 什么都不做,仅仅是个占位符
str = 'positive'
cont = 0
for i in str:
cont += 1
if i == 't':
break
print i
print 'count: %d' % cont
p
o
s
i
count: 5
str = 'positive'
cont = 0
for i in str:
cont += 1
if i == 't':
continue
print i
print 'count: %d' % cont
p
o
s
i
i
v
e
count: 8
str = 'positive'
cont = 0
for i in str:
cont += 1
if i == 't':
pass
print i
print 'count: %d' % cont
p
o
s
i
t
i
v
e
count: 8