exceptions_handle.py 221 B

123456789
  1. try:
  2. text = raw_input('Enter something --> ')
  3. except EOFError:
  4. print 'Why did you do an EOF on me?'
  5. except KeyboardInterrupt:
  6. print 'You cancelled the operation.'
  7. else:
  8. print 'You entered {}'.format(text)