-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