异常try...except

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


import sys

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

print 'Done'

原文地址:https://www.cnblogs.com/nku-wangfeng/p/7696639.html