Python 实现类似于Go语言中的延迟执行语句 上下文管理器(Context Manager)
def defer(msg: str, subject='参数错误'):
print('do----')
return f'{subject}:{msg}'
assert False, defer('66')
Python 实现类似于Go语言中的延迟执行语句(defer)|极客笔记 https://deepinout.com/python/python-qa/652_python_python_equivalent_of_golangs_defer_statement.html