附加到文本文件

时间:2010-02-16 13:38:30

标签: python text-files raw-input

  

可能重复:
  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()

此代码会在文本文件中添加文字,但不能准确地说明如何准确地制作文字?

0 个答案:

没有答案