# Reading and Writing Text Files

open() in a with block writes text to a file and reads it back, the mode says whether to write ("w"), add to the end ("a") or read ("r"), encoding="utf-8" keeps every letter intact, and a FileNotFoundError means the name or the folder is wrong.

![Cheat sheet: Reading and Writing Text Files](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/e9381ed161944e7ea24b22c811a33990.webp)

- Category: Python
- Level: Apprentice
- Tags: File Mode, FileNotFoundError, open(), python, text-encoding, with Statement
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/python-files-reading-and-writing-cheat-sheet
