python asyncio
例子
import asyncio
async def main():
print("hello")
await asyncio.sleep(1)
print("world")
asyncio.run(main())
主要函数
task = asyncio.create_tas()
res = await asyncio.gather(task1, task2) # res: list
获取返回值
res = await task
import asyncio
async def main():
print("hello")
await asyncio.sleep(1)
print("world")
asyncio.run(main())
task = asyncio.create_tas()
res = await asyncio.gather(task1, task2) # res: list
res = await task