首页 > 编程语言 > 详细

python的基本操作while循环体

时间:2020-07-03 10:39:15      阅读:53      评论:0      收藏:0      [点我收藏+]
#第一个案例==> while循环体
count = 1
while count <= 8 :
    print("这是第",count,"次")
    count = count + 1

#第二个案例==> break的使用
string = ""
while True :
    s = input("输入你想输入的内容:")
    if s == "q":
        break
    string += s
print(string)
#第三个案例 ==> continue的使用
string = ""
while True:
    s = input("输入你想输入的内容:")
    if(s == "q"):
        break
    if "abc" in s : #如果在输入的内容中有abc就不要加入待打印的字符串中
        continue
    string += s
print(string)

  

python的基本操作while循环体

原文:https://www.cnblogs.com/boost/p/13228545.html

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