我注意到在任何Python 3程序中,无论它有多基础,如果按下CTRL + C,程序都会崩溃,例如:
test=input("Say hello")
if test=="hello":
print("Hello!")
else:
print("I don't know what to reply I am a basic program without meaning :(")
如果按下CTRL c,将会出现“KeyboardInterrupt”错误。是否有任何方法可以防止程序崩溃?
我之所以想这样做,是因为我想让我的程序无误差。每当我想将某些内容粘贴到输入框中时,我不小心按下CTRL c,就必须重新运行程序...这太烦人了。