【发布时间】:2019-06-24 16:17:21
【问题描述】:
我知道在python37中我们有一个新的apiasyncio.get_running_loop(),它很容易使用,让我们在调用协程时不需要显式传递eventloop。
我想知道我们是否可以使用任何方法在 python36 中获得相同的效果?
# which allows us coding conveniently with this api:
import asyncio
async def test():
print("hello world !")
async def main():
loop = asyncio.get_running_loop()
loop.create_task(test())
asyncio.run(main())
【问题讨论】:
-
@user4815162342 确实,非常感谢!