在pycharm中调试代码时,按Ctrl + C时,我的python try / except循环似乎不会触发键盘中断。我的代码如下所示:
numbers = []
loop = True
try:
# ===========SUBROUTINES==================
def help():
print("To view the list type 'view'"
"\n To add an item type 'add'"
"\n To remove an item type 'remove'"
"\n To exit type exit or Ctrl + c can be used at any time")
# =========SUBROUTENES END===============
while loop:
task = input("What do you want to do? Type \"help\" for help:- ")
if task == 'help':
help()
else:
print("Invalid return please try …Run Code Online (Sandbox Code Playgroud)