python import asyncio import aiofiles async def read_file(file_path): async with aiofiles.open(file_path, mode='r') as file: content = await file.read() print(content) async def write_file(file_path): async with aiofiles.open(file_path, mode='w') as file: await file.write('Hello, aiofiles!') async def main(): file_path = 'example.txt' await read_file(file_path) await write_file(file_path) asyncio.run(main())


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