Advertisement
Guest User

This.

a guest
May 30th, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. 1 from sys import argv
  2. 2
  3. 3 script, filename = argv
  4. 4
  5. 5 print "We're going to erase %r." % filename
  6. 6 print "If you don't want that, hit CTRL- C (^C)."
  7. 7 print "If you do want that, hit RETURN."
  8. 8
  9. 9 raw_input("?")
  10. 10
  11. 11 print "Opening the file..."
  12. 12 target = open(filename, 'w')
  13. 13
  14. 14 print "Truncating the file. Goodbye!"
  15. 15 target.truncate()
  16. 16
  17. 17 print "Now I'm going to ask you for three lines."
  18. 18
  19. 19 line1 = raw_input("line 1: ")
  20. 20 line2 = raw_input("line 2: ")
  21. 21 line3 = raw_input("line 3: ")
  22. 22
  23. 23 print "I'm going to write these to the file."
  24. 24
  25. 25 target.write(line1)
  26. 26 target.write("\n")
  27. 27 target.write(line2)
  28. 28 target.write("\n")
  29. 29 target.write(line3)
  30. 30 target.write("\n")
  31. 31
  32. 32 print "And finally, we close it."
  33. 33 target.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement