Advertisement
Aws96

Reading and writing python

Jun 27th, 2014
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. #I want this code to write to the first file and then take the
  2. #contents of the first file and copy them to the second.
  3.  
  4. from sys import argv
  5.  
  6. script, file1, file2 = argv
  7.  
  8.  
  9. def write_to_file(fileread, filewrite):
  10.     '''Writes to a file '''
  11.     filewrite.write(fileread)
  12.  
  13.  
  14. input_file = open(file1, 'r+w')
  15. output_file = open(file2, 'w')
  16.  
  17. datain = raw_input(">")
  18. input_file.write(datain)
  19.  
  20. print input_file.read()
  21.  
  22. write_to_file(input_file.read(), output_file)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement