本帖最后由 wujunkai 于 2020-4-1 08:42 编辑
回复 1# netdzb | import re | | with open('text.txt','r') as fin: | | print(re.search(r'(?<=begin===).+?(?=end===)',fin.read(),re.DOTALL).group())COPY |
或者更简洁一点 | import re | | print(re.search(r'(?<=begin===).+?(?=end===)',open('text.txt','r').read(),re.DOTALL).group())COPY |
|