时间:2021-07-01 10:21:17 帮助过:21人阅读
def foo(): r = some_function() if r==(-1): return (-1) # do something return r def bar(): r = foo() if r==(-1): print 'Error' else: pass
但是Go就是这么干的,哈哈!
python 中还是用try … except….finally这种方式来处理的。
try: print 'try...' r = 10 / 0 print 'result:', r except ZeroDivisionError, e: print 'except:', e finally: print 'finally...' print 'END'