擅长:python、mysql、java
<p><code>break</code>和<code>continue</code>应用于最里面的循环。</p>
<p>问题是您只打开第二个文件一次,因此它只读取一次。当您第二次执行<code>for y in file2.readlines():</code>时,<code>file2.readlines()</code>返回一个空的iterable。</p>
<p>将<code>file2 = open(filename2, 'r')</code>移到外部循环中,或使用<code>seek()</code>返回到<code>file2</code>的开头。</p>