2024-10-06 13:03:09 发布
网友
假设我有一个这样的脚本
myInput = input(int('Enter a number: ')) while myInput > 0: print(myInput) myInput-=1
有没有一种方法可以中断while循环并返回到请求用户输入的部分
假设您指的是KeyboardInterrupt:
KeyboardInterrupt
def foo(): try: myInput = int(input('Enter a number: ')) while myInput > 0: print(myInput) myInput-=1 return True except KeyboardInterrupt: return False while not foo(): pass
假设您指的是
KeyboardInterrupt
:相关问题 更多 >
编程相关推荐