Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sys import argv
- script, filename = argv
- print "We're going to erase %r." % filename
- print "If you don't want that, hit CTRL-C (^C)."
- print "If you do want that, hit RETURN."
- raw_input("?")
- print "Opening the file..."
- target = open(filename, 'w')
- target.open(filename, 'r')
- print "Here we are:\n"
- print target.read()
- target.truncate()
- target.close()
- target.open(filename, 'w')
- print "Now I'm going to ask you for three lines."
- line1 = raw_input("Line1: ")
- line2 = raw_input("Line2: ")
- line3 = raw_input("Line3: ")
- print "I'm going to write these to the file."
- target.write("%s\n%s\n%s\n" % (line1, line2, line3))
- print "One moment please..."
- target.close()
- target = open(filename, 'w+')
- print target.read()
- enter = 'ENTER'
- print "Do you want to close it now? "
- print "Push %r for yes. CTRL-C for no." % enter
- print "And finally, we close it."
- raw_input(": ")
- target.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement