FileIO & Exceptions

Reading and Writing Files in Python

Opening and Closing a File

Character –> Meaning ‘r’ –> Open for reading (default) ‘w’ –> Open for writing, truncating (overwriting) the file first ‘rb’ or ‘wb’ –> Open in binary mode (read/write using byte data)

Python Exceptions: An Introduction

Exceptions versus Syntax Errors

Raising an Exception
Handling Exceptions Through try and except Block
The else Clause
the finally is used with the code that should always run