python import asyncio import aiofiles async def read_file(): async with aiofiles.open('example.txt', mode='r') as file: contents = await file.read() print(contents) async def write_file(): async with aiofiles.open('example.txt', mode='a') as file: await file.write('Hello, world') async def main(): await asyncio.gather(read_file(), write_file()) if __name__ == '__main__': asyncio.run(main())


上一篇:
下一篇:
切换中文