定义:
def intersect(seq1,seq2):
res = []
for x in seq1:
if x in seq2:
res.append(x)
yield res
运行效果
>>> s1 = "ATGC"
>>> s2 = "TGC"
>>> intersect(s1,s2)
<generator object intersect at 0x01AF7288>
>>> for i in intersect(s1,s2):
print i
['T', 'G', 'C']
>>>