impor = re
>>> name = '是'and'的'
>>> text = open('E:/西方哲学史.txt','r').read()
>>> results = re.findall(r'[^。]*?{}[^。]*?。'.format(name), text)
>>> for i, r in enumerate(results, 1):
... print(i,r)
>>> name = '是'and'的'
>>> text = open('E:/西方哲学史.txt','r').read()
>>> results = re.findall(r'[^。]*?{}[^。]*?。'.format(name), text)
>>> for i, r in enumerate(results, 1):
... print(i,r)
... with open('E:/a.txt','a+')as s:
... s.write(r)
s.close()