python for ,loop ,else condition test
when you use break jump out from for or while statement,if has else caluse,it will not exec,for example:
>>> for i in xrange(0,11):
print i
else:
print "haha,%s"%i
0
1
2
3
4
5
6
7
8
9
10
haha,10
>>> for i in xrange(0,11):
print i
if i>7:
print "jump"
break
else:
print "haha,%s"%i
0
1
2
3
4
5
6
7
8
jump
>>>
http://img.zemanta.com/pixy.gif?x-id=706d088c-64db-8b12-bfb2-0f33da5ec076
页:
[1]