Python While循环continue、break语句
1.while 循环 语句
spam = 0
while spam <5:
print("Hello Word:",spam)
spam +=1
2.while的break语句
name = ''
while name != "your name":
print("Now your name:",name)
name =input("请输入你的姓名:")
if name == "eric":
break
print('Hello Eric')
3.while的continue
while True:
print("who are you ?")
name = input("请输入姓名:")
if name != "Joe":
continue
#如果不是则继续上方的while循环
print("Hello.Joe.What's the password?")
password=input("请输入密码:")
if password == "software":
break
#如果正确则跳出循环
print("通过")
例
while打印出1-11
print("\n")
print("以下是While")
i=1
while i<11:
print(i)
i+=1
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。