with open('example.txt', 'w') as file: file.write('Hello, this is an example.') with open('example.txt', 'r') as file: content = file.read() print(f"Content of the file: {content}")
Output:
Content of the file: Hello, this is an example.
with open('example.txt', 'w') as file: file.write('Hello, this is an example.') with open('example.txt', 'r') as file: content = file.read() print(f"Content of the file: {content}")
Output:
Content of the file: Hello, this is an example.