python -- exception

#test for exception
import sys;

try:
    nVal = (int)(raw_input('enter:'));
except EOFError:
    print 'why did you do an EOF on me?\n';
    sys.exit();#exit the program;
except:
    print "other exception....\n";

#try--except & try-finally 不能同时使用
#finally:
#    print "input over...\n";

print 'input ok';
 

你可能感兴趣的:(python)