[問題]第二個For loop 只被執行一次
你好,請問不知道為什麼,我底下的for loop只會跑一次:
import os
output_file1=open('result_exception.txt','w',encoding="utf-8")
all_error_output=open('all_error_output.txt',encoding="utf-8")
exceptionlist=open('exceptionlist.txt',encoding="utf-8")
for each_line1 in all_error_output:
print(each_line1,end="",file=output_file1)
for each_line2 in exceptionlist:
print(each_line2,end="",file=output_file1)
output_file1.close()
exceptionlist.close()
all_error_output.close()
底下是all_error_output.txt內容
1;aaaa;1111
2;bbbb;2222
3;cccc;3333
底下是all_error_output.txt內容
1;aaaa;111
2;bbbb;222
底下是結果
1;aaaa;1111
1;aaaa;111
2;bbbb;222
2;bbbb;2222
3;cccc;3333
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 182.234.234.100
→
11/02 20:52, , 1F
11/02 20:52, 1F
推
11/02 20:59, , 2F
11/02 20:59, 2F
→
11/02 21:02, , 3F
11/02 21:02, 3F
→
11/02 21:06, , 4F
11/02 21:06, 4F
推
11/03 01:29, , 5F
11/03 01:29, 5F
→
11/07 00:16, , 6F
11/07 00:16, 6F
Python 近期熱門文章
PTT數位生活區 即時熱門文章