Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #http://learnpythonthehardway.org/book/ex17.html
- #
- #takes to file names
- #one file in and one file out
- #eg
- #C:\Python33>python PTHW17.py 1.txt.txt 2.txt
- from sys import argv
- from os.path import exists
- script, from_file, to_file =argv
- print ("Copying from {} to {}".format(from_file, to_file))
- #we could do this on one line but I don't know how yet
- in_file = open(from_file)
- indata = in_file.read()
- print ("The input file is {} long".format(len(indata)))
- print ("Does the output file exist? {}".format(exists(to_file)))
- print ("Ready? hit RETURN to continue. ctrl - c to abort")
- input()
- out_file = open(to_file,'w')
- out_file.write(indata)
- print ("Alright, all done.")# File {} is copied to File {}".format(from_file,out_file)))
- out_file.close()
- in_file.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement