Advertisement
Bad_luck

Untitled

Sep 27th, 2012
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1. from sys import argv
  2.  
  3. script, filename = argv
  4.  
  5.  
  6. print "We're going to erase %r." % filename
  7. print "If you don't want that, hit CTRL-C (^C)."
  8. print "If you do want that, hit RETURN."
  9.  
  10. raw_input("?")
  11.  
  12. print "Opening the file..."
  13. target = open(filename, 'w')
  14. target.open(filename, 'r')
  15. print "Here we are:\n"
  16. print target.read()
  17. target.truncate()
  18. target.close()
  19.  
  20. target.open(filename, 'w')
  21. print "Now I'm going to ask you for three lines."
  22.  
  23. line1 = raw_input("Line1: ")
  24. line2 = raw_input("Line2: ")
  25. line3 = raw_input("Line3: ")
  26.  
  27. print "I'm going to write these to the file."
  28.  
  29. target.write("%s\n%s\n%s\n" % (line1, line2, line3))
  30.  
  31. print "One moment please..."
  32. target.close()
  33. target = open(filename, 'w+')
  34. print target.read()
  35.  
  36. enter = 'ENTER'
  37. print "Do you want to close it now? "
  38. print "Push %r for yes. CTRL-C for no." % enter
  39. print "And finally, we close it."
  40.  
  41. raw_input(": ")
  42. target.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement