所以我希望能够将这段代码添加到 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()
这样多人就可以写下他们的建议,而不会被下一个人覆盖。
我希望它会自动添加到下面,而在另一个线程中似乎并非如此。
您需要更改w
为a
,即:file = open("Suggestions.txt", "a")
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句