import time def run(coroutine): try: print("11") coroutine.send(None) except StopIteration as e: print("e.value",e.value) return e.value async def async_function(): time.sleep(2) print("等待兩秒") return 1 async def await_coroutine(): await async_function() print("等待執行完成,再執行我") run(await_coroutine())
# 輸出結果
11
等待兩秒
等待執行完成,再執行我
e.value None