Why doesn't this python keyboard interrupt work? (in pycharm)

前端 未结 7 1246
被撕碎了的回忆
被撕碎了的回忆 2020-12-03 15:28

My python try/except loop does not seem to trigger a keyboard interrupt when Ctrl + C is pressed while debugging my code in pycharm. My code look like this:



        
7条回答
  •  鱼传尺愫
    2020-12-03 15:42

    From your screen shot it appears that you are running this code in an IDE. The thing about IDEs is that they are not quite the same as running normally, especially when it comes to handling of keyboard characters. The way you press ctrl-c, your IDE thinks you want to copy text. The python program never sees the character. Pehaps it brings up a separate window when running? Then you would select that window before ctrl-c.

提交回复
热议问题