可能重复:
Confused with appending to text file
How can I write to the textfile with “while”?
text_file = open("write_it.txt", "a")
while 1:
word = raw_input("Please add to a text file: ")
if not word:
break
text_file.write(word)
text_file.close()
此代码会在文本文件中添加文字,但不能准确地说明如何准确地制作文字?