使用Python将文件内容复制到另一个文件中

时间:2017-02-21 20:01:28

标签: python file

我要做的就是复制一个名为'example.txt'的文件的内容并将它们放入输出文件中。这就是我所拥有的,但是当我运行它时没有任何反应。我可能错过了一些显而易见但却无法弄清楚的东西。

def fcopy(fileName1,fileName2):
    fileIn=open(fileName1, 'r')
    fileOut=open(fileName2, 'w')
    for word in fileIn.readlines():
        fileOut.write(word)
    fileIn.close()
    fileOut.close()

这就是我所说的:

fcopy('example.txt','output.txt')
open('output.txt')

0 个答案:

没有答案