reading-notes

FileIO & Exceptions

Read & Write Files in Python

file = open(./file_path/file.ext, ‘mode’)

make sure to close your open files.

reader = open('dog_breeds.txt', 'r')
try:
    # Further file processing goes here
finally:
    reader.close()

or

with open('dog_breeds.txt', 'r') as reader:
    # Further file processing goes here

Exceptions in Python

References