python except and finally do not work with KeyboardInterrupt -
after executing following code, when press control+c, execution ends , nothing printed console
import time  x = 1  try:     while true:     print x     time.sleep(.3)     x += 1  except keyboardinterrupt:     print "bye"   finally:     print "this one"      
there indentation problem in code. if changed to:
import time  x = 1  try:     while true:         print x         time.sleep(.3)         x += 1  except keyboardinterrupt:     print "bye"   finally:     print "this one"   output is:
1 2 3 4 5 6 bye 1      wiki
Comments
Post a Comment