所以我有一个文本文档text_input 并且我想使用 python 将文本中的两个值拆分为两个单独的文本文档。.
非常感谢你们为互相帮助而付出的所有努力!
这应该这样做:
>>> with open('input.txt') as f1,open('output1.txt','w') as f2,open('output2.txt','w') as f3:
... for line in f1: #read data line by line
... lin=line.split() #split the line into ['19490622','14.0']
... f2.write(lin[0]+'\n') #write first part to output1
... f3.write(lin[1]+'\n') #write second part to output2