擅长:python、mysql、java
<p>替代方法。。。这确实奏效了。谢谢@Gabor Fekete。你知道吗</p>
<pre><code>import fnmatch #Imports the synx for itteratively searching through Files
import os
import re #regex Expressions
for file in os.listdir('/.'): #Goes through Files in Directory
if fnmatch.fnmatch(file, '*.sum'): # Selects files with .sum extension
lattE = open(file,"r") #opens said files
lattEW = open("Latt_En.txt", "a") #Amends Summary file
for line in lattE: # Goes through file
if re.match("(.*)(L)ATTICE(.*)", line): #Searches for term LATTICE
print >>lattEW, lattE.name, line, #Prints to LattEW file , name and line
</code></pre>