Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. from sys import argv
  2.  
  3. #Provides the user with two parameters to type before running the script.
  4. script, filename = argv
  5.  
  6. # Opens whatever the user chooses that 'filename' represents.
  7. txt = open(filename)
  8.  
  9. # replaces %r with the 'filename' This also places the 'filename' in quotes.
  10. print "Here's your file %r" % filename
  11.  
  12. # This allows 'txt' which is 'open(filename)' to run
  13. print txt.read()
  14.  
  15. print "I'll also ask you to type it again:"
  16.  
  17. # Allows the user to type in the filename again
  18. file_again = raw_input("> ")
  19.  
  20. # File_again will equal whatever the user chooses. file again will now equal txt again
  21. txt_again = open(file_again)
  22.  
  23. # This line allows the txt_again code to run
  24. print txt_again.read()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement