2012-10-24 75 views

回答

2

這應該這樣做:

>>> 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 
+0

感謝堆,英雄! –

+1

很高興幫助:)。另請參閱[如何做 - 接受答案 - 工作](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235) –

相關問題