所以我需要做一個代碼,打開一個txt文件,然後把該文件的內容並將其放入另一個txt文件,問題是,我不知道如何從文件中提取信息的命令,我做了一些研究,發現這是最接近的事情,但它只是不是我所需要的:How do I get python to read only every other line from a file that contains a poem如何讓Python從文本文件中讀取和提取單詞?
這是到目前爲止我的代碼:
myFile = open("Input.txt","wt")
myFile.close()
myFile = open("Output.txt","wt")
myFile.close()
你可能已經錯過了「[讀取和寫入文件(https://docs.python.org/3/tutorial/inputoutput .html#reading-and-writing-files)「。 – Matthias