⽤while语句输出1234568910 import time
count=1
while count<=10:
print(count,time.time())
if count != 6:
count=count+1
else:
count=count+2
print('the end')
while语句简单例子采⽤tinue语句
count=1
while count<10:
if count==7:
count=count+1
continue
print(count)
count = count + 1
else:
print('else')
输出为:
1
2
3
4
5
6
8
9
continue终⽌当前循环,进⾏下⼀次循环,break终⽌所有循环
count=0
while count<3:
user=input('please input ID>>>>>:')
pwd=input('please input your psaaword')
if user == '''hello'''and pwd == '''world''':
print('welcome to the unit')
break
else:
print('try it again')
continue
输出为:
please input ID>>>>>:90
please input your psaaword90
try it again
please input ID>>>>>:90
please input your psaaword90
try it again
please input ID>>>>>:hello
please input your psaawordworld
welcome to the unit

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。