← All lessons

Lesson 11 of 18 · about 14 minutes

Reading and Writing Files 📄

Reading and Writing Files 📄 Real programs persist data. The with statement opens a file and closes it automatically, even if an error happens. with open("notes.txt", "w") as f: f.write("First line\n") f.write("Second line\n") with open("notes.txt") as f: #…

This lesson is part of Pythonaut Pro. The full Launchpad track is free forever, so you can start there and come back.

See the free lessons