标签:bsp end 学习 换行 strong bre 语句 python nbsp
while循环语句
age = 50
guss_age = int(input("请输入您猜测的年龄:"))
while guss_age !=age:
if guss_age > age:
print("您猜大了:请重试!")
else:
print("您猜小了:请重试!")
guss_age = int(input("请输入您猜测的年龄:"))
print("您猜对了!")
while 条件:
.....
else: #只有while语句里有break,else 语句才不会执行
.....
break 终止
num =0
while num <10:
print(num)
num = num +1
break
continue跳出当次循环,继续从头开始
num = 1
while num <=10:
num = num +1
if num == 3:
continue
print(num)
结果:
2
4
5
6
7
8
9
10
11
三行语句不换行
print("hallo word")
print("hallo word")
print("hallo word")
print("hallo word",end ="___")
print("hallo word",end ="___")
print("hallo word",end ="___")
num1 = 0
num2 = 0
while num1<=5:
print(num1,end="_")
num2 = 0
while num2 <=7:
print(num2,end="-")
num2+=1
num1+=1
print(end = "\n") #等价于print()
结果:
0_0-1-2-3-4-5-6-7-
1_0-1-2-3-4-5-6-7-
2_0-1-2-3-4-5-6-7-
3_0-1-2-3-4-5-6-7-
4_0-1-2-3-4-5-6-7-
5_0-1-2-3-4-5-6-7-
python学习20200509while循环语句
标签:bsp end 学习 换行 strong bre 语句 python nbsp
原文地址:https://www.cnblogs.com/wangyunpeng888888/p/12859304.html