当前位置: Python基础教程 > 03-流程控制 > 阅读正文

python的while语句

2021.6.10.   578 次   156字

while语句是常用的循环语句之一

语法如下

while 条件表达式:
    语句体;

while语句实例

输出100次hello

index=0
while index<100:
    print("hello"+str(index))
    index += 1

从hello0到hello99, 正好是100次, 一般来说, 从0开始, <n, 就刚好是 n 次循环

本篇完,还有疑问?

加入QQ交流群:11500065636 IT 技术交流群