【发布时间】:2019-04-17 16:28:21
【问题描述】:
我想加载/读取一个文本文件并将其“完全”写入另外两个文本文件。稍后我会将其他不同的数据写入这两个文件的以下内容。 问题是加载的文件只写入第一个文件,而加载的文件中没有数据写入第二个文件。
我正在使用的代码:
fin = open("File_Read", 'r')
fout1 = open("File_Write1", 'w')
fout2 = open("File_Write2", 'w')
fout1.write(fin.read())
fout2.write(fin.read()) #Nothing is written here!
fin.close()
fout1.close()
fout2.close()
发生了什么,解决方案是什么? 我更喜欢使用 open 而不是 with open。
谢谢。
【问题讨论】:
标签: python file read-write