当前时间

while循环语句

# while 循环
# 循环: 不断的重复着某件事情就是循环
# while 关键字

# while True:   # 死循环
#     print("坚强")
#     print("过火")
#     print("单身情歌")
#     print("郭德纲的小曲")
#     print("五环之歌")
#     print("鸡你太美")
#     print("大碗宽面")
# print("痒")

# print(1111)
# while True:   # 死循环
#     print("坚强")
#     print("过火")
#     print("鸡你太美")
#     print("大碗宽面")
# print(333)

# 循环5次
# count = 0
# while True:  # 死循环
#     count = count + 1  # 先执行 = 右边的内容
#     if count == 5:
#         print(count)
#         break # 有限循环


# count = 0
# while True:  # 死循环
#     count = count + 1  # 先执行 = 右边的内容
#     if count == 5:
#         print(111)
#         continue  # continue 就是伪装成循环体中最后一行代码
#     print(count)

# count = 0
# while True:  # 死循环
#     count = count + 1  # 先执行 = 右边的内容
#     continue  # continue 就是伪装成循环体中最后一行代码
#     print(count)


# while循环中的两个关键字:
# break : continue
# break : 终止当前循环
# continue : 跳出本次循环,继续下次循环 (就是伪装成循环体中最后一行代码)
# continue 和 break下方的代码都不会执行

# while 条件:
# 缩进 循环体

# 通过条件控制循环次数

# count = 0
# while count < 2:
#     print(count)
#     count = count + 1

# 4 ~ 67 (包含4和67)

# count = 4
# while count < 68:
#     print(count)
#     count = count + 1

# 100 ~ 6 包含(100和6)

# count = 100
# while count > 5:
#     print(count)
#     count = count - 1

# 1,3,5,7,9
    # count = 1
    # while count < 10:
    #     print(count)
    #     count = count + 2

# while else 与 if else 相似

# print(222)
# count = 0          # 计算器
# while count < 3:
#     print(count)   # 一直死循环,计算器没有进行计算
#
# print(111)

# print(222)
# count = 0
# while count < 3:
#     print(count)
#     count = count + 1
# print(111)


# print(222)
# count = 0
# while count < 3:
#     print(count)
#     count = count + 1
# else:
#     print(111)

# print(222)
# count = 0
# while count < 3:
#     print(count)
#     count = count + 1
#     break
# print(111)

# 运行结果 : 222 0 111

# print(222)
# count = 0
# while count < 3:
#     print(count)
#     count = count + 1
#     break
# else:
#     print(111)

# 运行结果: 222 0

# print(222)
# count = 0
# while count < 3:
#     print(count)
#     count = count + 1
# else:
#     print(111)

# 运行结果: 222 0 1 2 111
posted @ 2019-09-06 16:06  Donkeys  阅读(128)  评论(0编辑  收藏  举报