Catch exception throwed inside a function,exceptionthrowed,def f():
Catch exception throwed inside a function,exceptionthrowed,def f():
def f(): print 'in f, before 1/0' 1/0 # raises a ZeroDivisionError exception print 'in f, after 1/0'def g(): print 'in g, before f()' f() print 'in g, after f()'def h(): print 'in h, before g()'try: g() print 'in h, after g()'except ZeroDivisionError: print 'ZD exception caught'print 'function h ends'
相关内容
- Using the continue statement in a for/in structure.,statementstruct
- Divided by int or by float,dividedfloat,from __futur
- Read a number and do the divide by 2,numberdivide,num = raw_in
- Loop can be applied to any 'iterable' object,applie
- if-elif-else structure,if-elif-else,import rando
- if with else,ifelse,name = raw_i
- Logical operators conditions,logicaloperators,username = '
- Fetches an already-loaded module,,#//simple.py
- Change referenced variable value,referencedvariable,#//File: sma
- pprint module offers more sophisticated control over printing,,#The
评论关闭