def method_with_exception(): try: raise Exception("test exception") except Exception as ex: # 实现任意部分处理, # 并把错误传给调用方代码 raise extry: method_with_exception()except Exception as e: print(e.args[0])