async 与 await

48.1 async 与 await

async def 定义协程,await 等待异步操作。

简单协程

import asyncio
async def hello():
    print('你好')
    await asyncio.sleep(1)
    print('异步完成')
asyncio.run(hello())