Advertisement
pleabargain

PTHW15.py

May 3rd, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. #http://learnpythonthehardway.org/book/ex15.html
  2. #c:python33 python ex15.py arg_filename
  3. #keep in mind the file name has to be exact... under windows what you see
  4. #is not always what you get
  5. #there are instances where you will want to run dir
  6. #at the windows command line to make sure the file you want is really there
  7.  
  8. from sys import argv
  9.  
  10. script, filename = argv #this is going to call the txt file
  11.  
  12. txt = open(filename)
  13.  
  14. print ("Here's your file {}".format(filename))
  15.  
  16. print (txt.read())
  17. #close (txt.read()) # this doesn't work
  18. txt.close()
  19. again = input ("filename again please:")
  20.  
  21. txt_again = open(again)
  22.  
  23. print (txt_again.read())
  24. txt_again.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement