Created
February 27, 2014 20:25
-
-
Save blammothyst/9258801 to your computer and use it in GitHub Desktop.
Code from Learn Python the Hard Way(.org) ex 16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | |
print "Truncating the file. Goodbye!" | |
target.truncate() | |
print "Now I'm going to ask you for three lines." | |
line1 = raw_input ("line 1: ") | |
line2 = raw_input ("line 2: ") | |
line3 = raw_input("line 3: ") | |
txt2 = ("%r\n%r\n%r\") % ( line1, line2, line3) | |
print "I'm going to write these to the file." | |
target.write(txt2) | |
print "And finally, we close it." | |
target.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment