Appearance
捕获函数执行过程中的错误并返回指定值
from usepy import catch_error
return_val
>>> import logging >>> logging.basicConfig(level=logging.DEBUG) >>> >>> @catch_error(return_val=0) ... def divide(a, b): ... return a / b >>> >>> divide(10, 2) 5.0 >>> divide(10, 0) 0