浙江省高等学校教师教育理论培训

微信搜索“毛凌志岗前心得”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
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
>>>


posted on 2010-05-31 14:48  lexus  阅读(197)  评论(0编辑  收藏  举报