Writing Files in Python

We're going to learn how to write files in python

We'll cover the following...

If you have been following along, you can probably guess what the file-mode flag is for writing files: “w” and “wb” for write-mode and write-binary-mode. Let’s take a look at a simple example, shall we?

CAUTION: When using “w” or “wb” modes, if the file already exists, it will be overwritten with no warning! You can check if a file exists before you open it by using Python’s os module.

Access this course and 1400+ top-rated courses and projects.