open python file window you see an editor in which you can type the example code type the following code into the window -pressing enter after each lineimport sys tryfile open('myfile txt'except ioerror as eprint("error opening file!\ \ "error number{ }\ \nformat( errno"error text{ }format( strerror)elseprint("file opened as expected "file close()this example uses some advanced features the import statement obtains code from another file tells you how to use this python feature the open(function opens file and provides access to the file through the file variable tells you how file access works given that myfile txt doesn' exist in the application directorythe operating system can' open it and will tell python that the file doesn' exist trying to open nonexistent file generates an ioerror exception this particular exception provides access to two argumentserrnoprovides the operating system error number as an integer strerrorcontains the error information as human-readable string the as clause places the exception information into variableethat you can access as needed for additional information the except block contains print(call that formats the error information into an easily read error message if you should decide to create the myfile txt filethe else clause executes in this caseyou see message stating that the file opened normally the code then closes the file without doing anything with it choose runrun module you see python shell window open the application displays the error opening file informationas shown in figure -