Python — From Basics to Advanced · Files and I/O
Reading and Writing Text Files
Files and I/O
Introduction
open() is a built-in function for opening files. The mode determines what you do with them: "r" — read, "w" — write (overwrites!), "a" — append to the end.