Generation

generate functionSat, 15 Apr 2023

file read asyncrounus

import asyncio async def read_file(filename): file = open(filename, 'r') data = file.read() file.close() return data loop = asyncio.get_event_loop() task = asyncio.ensure_future(read_file('sample.txt')) loop.run_until_complete(task) print(task.result())

Questions about programming?Chat with your personal AI assistant