python中循环有两种,while和for循环。
在while循环中,当while值为true时,while循环会一直进行下去(无限循环),直到当while值为false时,while循环才会停止。
#while循环结构(无限循环)#
a = True #while值#
while a :
print("hello,world!")
#简单完整while循环结构示例(带终止条件)#
a = 1
while a < 20 :
a += 1
print(a)
#简单交互式while循环结构示例(注意数字输入默认字符需要转换)#
a = int(input("input your number:\n"))
while a <= 20 :
a += 1
print(a)