“Async-Sync” Kode Jawaban

Async-Sync

def get_chat_id(name):
    time.sleep(3)
    return "chat-%s" % name

async def main():
    result = get_chat_id("django")
Amused Antelope

Async-Sync

async def get_chat_id(name):
    await asyncio.sleep(3)
    return "chat-%s" % name

async def main():
    id_coroutine = get_chat_id("django")
    result = await id_coroutine
Amused Antelope

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya