擅长:python、mysql、java
<pre><code>wfiles = ['a.txt','b.txt','c.txt']
ylist = ['grapes', 'name']
for w in wfiles:
with open(w) as ofiles:
if any(word in ofiles.read().split() for word in ylist):
print "Found"
else:
print "Not Found"
</code></pre>
<p>可以将file read()与文件中的所有单词一起使用。根据你的代码,你总是得到第一行,如果第一行中的单词列表不匹配,你就会中断。-</p>