Continue writing in same line of file

后端 未结 3 1550
难免孤独
难免孤独 2020-12-17 01:57

I have opened the file I want to write to using:

data = open(\'input\',\'a\')

using a loop, I want to write some words to the file in the s

3条回答
  •  时光说笑
    2020-12-17 02:33

    Remove the newline at the end of tag before writing it.

    data.write(str(tag).rstrip('\n'))
    

提交回复
热议问题