python/Context_Managers.py

6 lines
130 B
Python

with open('notes.txt', 'w') as file:
file.write("This is a note.")
print("File has been written and closed automatically.")