当前位置:首页 » 编程语言 » pythonwhile用法

pythonwhile用法

发布时间: 2025-10-13 04:26:03

pythonwhile循环的用法是什么

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!

热点内容
java返回this 发布:2025-10-20 08:28:16 浏览:710
制作脚本网站 发布:2025-10-20 08:17:34 浏览:972
python中的init方法 发布:2025-10-20 08:17:33 浏览:681
图案密码什么意思 发布:2025-10-20 08:16:56 浏览:833
怎么清理微信视频缓存 发布:2025-10-20 08:12:37 浏览:741
c语言编译器怎么看执行过程 发布:2025-10-20 08:00:32 浏览:1081
邮箱如何填写发信服务器 发布:2025-10-20 07:45:27 浏览:312
shell脚本入门案例 发布:2025-10-20 07:44:45 浏览:192
怎么上传照片浏览上传 发布:2025-10-20 07:44:03 浏览:879
python股票数据获取 发布:2025-10-20 07:39:44 浏览:837