原文:https://blog.csdn.net/zV3e189oS5c0tSknrBCL/article/details/80906206
import asyncio
import aiofiles
async def myopen():
async with aiofiles.open('333.log', encoding='utf8') as file:
contents = await file.read()
print('my read done, file size is {}'.format(len(contents)))
async def test_read():
print('begin readfile')
await myopen()
print('end readfile')
async def test_cumpute(x, y):
print("begin cumpute")
await asyncio.sleep(0.2)
print('end cumpute')
return x + y
def got_result(future):
print('The result