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.

By

Updated

Cheat sheet: Reading and Writing Text Files
Category
Python
Level
Apprentice
Tags
File Mode, FileNotFoundError, open(), python, text-encoding, with Statement