files and exceptions unit structure objective text files the file object attributes directories built-in exceptions handling exceptions exception with arguments user-defined exceptions summary exercise references objective to understand how python will raise an exception to create program to catch an exception using try/except block to study the python errors and exceptions to study creation and use of read and write commands for files in python to understand how to openwrite and close files in python text files now we will learn about various ways to read text files in python the following shows how to read all texts from the readme txt file into stringwith open('readme txt'as flines readlines(steps for reading text file in pythonto read the text file in the pythonyou have to follow these steps