上传文件至「week12」
This commit is contained in:
21
week12/ex6.py
Normal file
21
week12/ex6.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from continueanyway import ca
|
||||
|
||||
def handleArithmeticError(lmbd):
|
||||
def runlambda(*args,**kwargs):
|
||||
try:
|
||||
return lmbd(*args,**kwargs)
|
||||
except ArithmeticError:
|
||||
print("ArithmeticError detected!")
|
||||
return runlambda
|
||||
|
||||
@handleArithmeticError
|
||||
def div(a,b):
|
||||
return a/b
|
||||
|
||||
def main():
|
||||
print(div(1,0))
|
||||
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user