Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python
- # e.g. from docs.python.org/2/tutorial/errors.html
- import sys
- try:
- f = open('myfile.txt')
- s = f.readline()
- i = int(s.strip())
- except IOError as e:
- print "I/O error({0}): {1}".format(e.errno, e.strerror)
- except ValueError:
- print "Could not convert data to an integer."
- except:
- print "Unexpected error:" sys.exc_info()[0]
- raise
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement