异常try...except

#!/usr/bin/python
# Filename: try_except.py


import sys

try:
    s = raw_input('Enter something --> ')
except EOFError:
    print '\nWhy did you do an EOF on me?'
    sys.exit() # exit the program
except:
    print '\nSome error/exception occurred.'
    # here, we are not exiting the program

print 'Done'

posted @ 2017-10-20 00:30  真勇士王小山  阅读(110)  评论(0编辑  收藏  举报