Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from optparse import OptionParser
- try:
- # assumes file was specified as argument in the command line using optparse with --file option
- file=open(options.file, 'r')
- except FileNotFoundError: # works for python3
- print("Could not find file")
- sys.exit()
- except IOError:
- print("Could not open file")
- sys.exit()
- # iterate over the file
- for line in file:
- print(line.rstrip())
Add Comment
Please, Sign In to add comment