如何在IDLE中调用输入变量而不每次使用f5



这只是一些代码,我想找到一种运行代码的方法,而不必每次都按f5。我正在寻找一个命令或方法来调用输入变量。因为当我把print(x(放在IDLE shell中时,它会给我输入值。我可以使用无限循环,但我想知道这是否可能?

x = int(input("Please enter an integer: "))
if x < 0:
x = 0
print('Negative changed to zero')
elif x == 0:
print('Zero')
elif x == 1:
print('Single')
else:
print('More')

您可以使用一个无限循环:

while (True):
x = int(input("Please enter an integer: "))
if x < 0:
x = 0
print('Negative changed to zero')
elif x == 0:
print('Zero')
elif x == 1:
print('Single')
else:
print('More')

最新更新