Store all items from filename to another then return that file

This question already has an answer here:

  • How do I copy a file in python? 14 answers

  • 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

    上一篇: python将文件复制到Windows上的网络位置,而无需映射驱动器

    下一篇: 将所有项目从文件名存储到另一个然后返回该文件