asyncio 异步 并发

import asyncio

async def hello():
    print("Hello world!")
    await asyncio.sleep(1)
    print("Hello again!")

loop = asyncio.get_event_loop()
tasks = [hello(), hello(),hello(), hello()]
loop.run_until_complete(asyncio.wait(tasks))
loop.close()
发布了185 篇原创文章 · 获赞 11 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/huanghong6956/article/details/102772945