So lets say i was given a function to store whatever is in one filename to a different file name, how would i do that?
def return_newfile(self, filename):
......
.....
....
self.return_newfile(data)
So lets say i was given a function to store whatever is in one filename to a different file name, how would i do that?
def return_newfile(self, filename):
......
.....
....
self.return_newfile(data)
This is one way to do what I believe you want.
file1 = open("filename1","r")
file1_contents = file1.read()
file1.close()
file2 = open("filename2","w")
file2.write(file1_contents)
file2.close()
Now, there may be a better way to do what you want, like if you just want to copy a file without doing anything to the contents in between. However, if you want to process the contents, this is probably the way to go.