Store all items from filename to another then return that file
This question already has an answer here:
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.
链接地址: http://www.djcxy.com/p/42336.html