心海恋歌 发表于 2017-4-21 10:56:39

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';

 
页: [1]
查看完整版本: python -- exception