首页 > 编程语言 > 详细

Python---循环语句

时间:2014-08-29 03:05:27      阅读:257      评论:0      收藏:0      [点我收藏+]
1.for循环
#!/usr/bin/evn python
#Filename: for.py

for i in range(1, 5):
    print i
else:
    print ‘The for loop is over‘

2.break语句
#!/usr/bin/evn python
#filename: break.py

while True:
    s = raw_input(‘Enter something : ‘)
    if s == ‘quit‘:
        break
    print ‘Length of the string is‘, len(s)
print ‘Done‘

3.continue语句
#!/usr/bin/evn python
#filename: continue.py

while True:
    s = raw_input(‘Enter something:‘)
    if s == ‘quit‘:
        break
    if len(s) < 3:
        continue
    print ‘Input is of sufficient length‘


本文出自 “笔记” 博客,请务必保留此出处http://sunflower2.blog.51cto.com/8837503/1546260

Python---循环语句

原文:http://sunflower2.blog.51cto.com/8837503/1546260

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!