• Python基础-----while循环语句


    while循环语句会执行条件成立下的代码块,同样需要注意缩进与冒号。

     1 #!/usr/bin/env python 3
     2 # -*- coding:utf-8 -*-
     3 
     4 #1、基本的while语句
     5 '''
     6 while 条件为真:
     7     代码块
     8 '''
     9 #条件为真则代码块中的内容会永远执行下去
    10 
    11 #2、while同样可以与else搭配使用
    12 '''
    13 while  条件为真:
    14     代码块
    15 else:
    16     代码块
    17 '''
    18 
    19 #3、while中的continue与break
    20 
    21 #    A continue语句
    22 '''
    23 while 条件为真:
    24     代码块
    25     continue(用于终止当前循环,进行下一次循环)
    26 '''
    27 #    B break语句
    28 '''
    29 while 条件为真:
    30     代码块
    31     break(用于终止所有循环,不再进行循环)
    32 '''
  • 相关阅读:
    灌注和宝石性道法价比分析
    bzoj1912
    bzoj3504
    poj3580
    bzoj1251
    bzoj3223
    bzoj1212
    bzoj3790
    记一次惨痛的比赛
    bzoj2734
  • 原文地址:https://www.cnblogs.com/Meanwey/p/9496592.html
Copyright © 2020-2023  润新知