<p>我用Python3编写了这些程序,第一个只包括'@'符号后面的测试,第二个包括整个测试名称:</p>
<pre><code>file1=open("file1.txt")
file2=open("file2.txt")
file3=open("file3.txt")
f1=file1.read().split("\n")
f2=file2.read().split("\n")
f3=file3.read().split("\n")
file1.close()
file2.close()
file3.close()
f1s,f2s,f3s=[],[],[] #file1 split, file2 split, file3 split
try: [f1s.append(i.split("@")[1]) for i in f1]
except IndexError: pass
try: [f2s.append(i.split("@")[1]) for i in f2]
except IndexError: pass
try: [f3s.append(i.split("@")[1]) for i in f3]
except IndexError: pass
match2=0
for i in f2s:
if i[-1:]=="*":
i=i[:-1]
if [e for e in f1s if e[:len(i)]==i]: match2+=1
elif i in f1s: match2+=1
match3=0
for i in f3s:
if i[-1:]=="*":
i=i[:-1]
if [e for e in f1s if e[:len(i)]==i]: match3+=1
elif i in f1s: match3+=1
print("file 2:", match2, "tests found")
print("file 3:", match3, "tests found")
</code></pre>
<p>第二个程序:</p>
<pre><code>f1=open("file1.txt")
f2=open("file2.txt")
f3=open("file3.txt")
f1s=f1.read().split("\n")
f2s=f2.read().split("\n")
f3s=f3.read().split("\n")
f1.close()
f2.close()
f3.close()
match2=0
for i in f2s:
if i[-1:]=="*":
i=i[:-1]
if [e for e in f1s if e[:len(i)]==i]: match2+=1
elif i in f1s:
match2+=1
match3=0
for i in f3s:
if i[-1:]=="*":
i=i[:-1]
if [e for e in f1s if e[:len(i)]==i]: match3+=1
elif i in f1s:
match3+=1
print("file 2:", match2)
print("file 3:", match3)
</code></pre>
<p>通过我所做的测试,它们似乎都可以工作,并且也支持通配符,但是如果其中任何一个有问题,请给出注释。你知道吗</p>
<p>希望这有帮助。你知道吗</p>