Advertisement
brilliant_moves

ReadFile.py

Feb 6th, 2015
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. #!/usr/bin/python
  2. #ReadFile.py
  3. #Python 2.7
  4. #Read & display contents of text file
  5. #Chris Clarke
  6. #13.08.2014
  7.  
  8. filename = raw_input("Enter name of text file to open: ")
  9. try:
  10.    with open(filename) as f:
  11.       for line in f:
  12.          print line,
  13. except IOError:
  14.    print "Error opening file:", filename
  15. else:
  16.    f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement