-1
所以我想能夠將這段代碼添加到Suggestions.txt中,而不是替換那裏已經存在的內容(即現有內容下面兩行)如何添加到文件而不是替換
input1 = input("What is your name?: ")
input2 = input("What is your suggestion for another issue to be solved: ")
input3 = input("Do you know how to solve this issue? If not press enter: ")
input4 = input("What keywords would the user need to use to access the solution? \n Press enter to leave blank: ")
file = open("Suggestions.txt", "w")
file.write("Name: " +input1 + "\n")
file.write("Suggestion: " +input2 + "\n")
file.write("Solution: " +input3 + "\n")
file.write("Keywords: " +input4 + "\n")
file.close()
這樣,多個人可以寫下他們的建議,而不會被下一個人所忽略。
我想它會自動添加到下面,而這似乎不是在其他線程中的情況。
的[?你怎麼附加到文件(可能的複製http://stackoverflow.com/questions/4706499/how-do-you-附加到文件) – bejado
它不是重複的。 –
請確定你的問題與衆不同。 – bejado