2017-07-24 110 views
0

无论出于何种原因,我的代码未在第85行中输入'for'循环。未输入'for'循环? Python2.7

文件input_fileA已打开。有谁知道为什么?这是python 2.7。

84 if (counter_shiftA == counter_shiftB): 
85  for line in input_fileA: 
86   print line 
87   if shiftBEntryA.strip() in line: 
88    print "Hit a matched line" 
89    counter1 += 1 
90    flag = True 
91    output_file.write(line) 
92   elif shiftEEntryA.strip() in line: 
93    output_file.write(line) 
94    break 
95   elif flag: 
96    output_file.write(line) 
+0

什么是input_fileA的声明? –

+0

'counter_shiftA == counter_shiftB'评估为'True'吗? – zwer

+0

'input_fileA'已经用尽了吗?还是空的? –

回答

1

您可以尝试的line 87for line in input_file1.readlines():前添加input_file1.seek(0)。既然,你提到你之前已经打过电话了。 欲了解更多详细信息,你可以检查discussion here

+0

这样做,谢谢开源! :) –

+0

太棒了! '快乐的编码'。 – 0p3n5ourcE