File IO with Exception Handling
You can also have specific cases:
The
except
clause will run only if there is aTypeError
(Which is an object)
There is also an additional clause called finally
finally
finally
is a clause that will always run, no matter what
If you are dealing with files there are sometimes errors that variables are not accessible
In that case you would implement this in another
try
blockThis can get confusing though so be careful
IOError
is a type where it handles all the file issues, such as:No permission
Was not accessible
Does not have write permissions
Does not exist
Any issue with working with the file
Last updated