python 循环 while

Posted on 2019-04-21 22:05  S-skill  阅读(124)  评论(0编辑  收藏  举报
1. 循环
count = 1
while count <= 5:
    print("大家好!")
    count = count + 1
# 输出:
大家好!
大家好!
大家好!
大家好!
大家好!

 



结果:while 可以进行循环, count 表示计数, 而while count <=5:
限制循环的范围, count = count + 1 第一次循环后加1进行第二次
循环, 不超过循环的范围.
 





Copyright © 2024 S-skill
Powered by .NET 8.0 on Kubernetes