f.write(line + '''
''')
原代码
line = input()
while line:
with open('test.txt','a') as f:
f.write(line + '''
''')
line = input()
f.write(line + '''
''')
原代码
line = input()
while line:
with open('test.txt','a') as f:
f.write(line + '''
''')
line = input()