Guest User

Untitled

a guest
May 27th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. import sys
  2. from optparse import OptionParser
  3.  
  4. try:
  5. # assumes file was specified as argument in the command line using optparse with --file option
  6. file=open(options.file, 'r')
  7. except FileNotFoundError: # works for python3
  8. print("Could not find file")
  9. sys.exit()
  10.  
  11. except IOError:
  12. print("Could not open file")
  13. sys.exit()
  14.  
  15. # iterate over the file
  16. for line in file:
  17. print(line.rstrip())
Add Comment
Please, Sign In to add comment