Writing Files in Python
We're going to learn how to write files in python
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.
Get hands-on with 1400+ tech skills courses.