Here's the code:
try:
input() # I hit Ctrl+C
except Exception as e:
print(str(e))
Here's the traceback:
Traceback (most recent call last):
File "C:\Users\User\Desktop\test.py", line 2, in <module>
input()
KeyboardInterrupt
please, be explicit, when you want to catch KeyboardInterrupt:
try:
input() # I hit Ctrl+C
except Exception as e:
print(str(e))
except KeyboardInterrupt :
print 'ok, ok, terminating now...'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With