用re或者string.find.以下是re代码

1



2



3



4



5



6



7



8



9



10



11



12



13



14



15


import       re     


       #文本所在TXT文件     


       file       =       '123.txt'     


             


       #关键字1,2(修改引号间的内容)     


       w1       =       '123'     


       w2       =       '456'     


             


       f       =       open      (      file      ,      'r'      )     


       buff       =       f.read()     


       #清除换行符,请取消下一行注释     


       #buff = buff.replace('\n','')     


       pat       =       re.      compile      (w1      +      '(.*?)'      +      w2,re.S)     


       result       =       pat.findall(buff)     


       print      (result)