python while循环语句是什么?

如题所述

python while循环语句是:while 判断条件(condition);执行语句(statements)。

执行语句可以是单个语句或语句块。判断条件可以是任何表达式,任何非零、或非空(null)的值均为true。

当判断条件假 false 时,循环结束。

实例:

#!/usr/bin/python

 count = 0

while (count < 9):

   print 'The count is:', count

   count = count + 1

 print "Good bye!"

运行实例 »

以上代码执行输出结果:

The count is: 0

The count is: 1

The count is: 2

The count is: 3

The count is: 4

The count is: 5

The count is: 6

The count is: 7

The count is: 8

Good bye!

温馨提示:答案为网友推荐,仅供参考