小编Edw*_*win的帖子

为什么此python键盘中断不起作用?(在pycharm中)

在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)

python keyboardinterrupt pycharm try-except

7
推荐指数
3
解决办法
1万
查看次数

标签 统计

keyboardinterrupt ×1

pycharm ×1

python ×1

try-except ×1