我有一个像这样的文件,它在分隔符之间有多行,我想捕获 start_of_compile 和 end_of_compile 之间的所有内容(不包括注释)。
我想解析下面文本的字符串
#####start_of_compile - DO NOT MODIFY THIS LINE#############
##################################################################
parse these lines in between them
...
....
###################################################################
#####end_of_compile -DO NOT MODIFY THIS LINE#################
###################################################################
我想看到匹配(.*)来匹配开始和结束之间的多行。目前还没有
相反,我看到下面的错误
def checkcompileqel():
compiledelimiters = ['start_of_compile_setup']
with open("compile.qel", "r") as compile_fh:
lines = compile_fh.read()
matchstart = re.compile(r'^#+\n#+start.*#+\n#+(.*)#+\n#+end.*#+\n#+',re.MULTILINE)
print(matchstart.match(lines).group(1))
Traceback (most recent call last):
File "/process_tools/testcode.py", line 25, in <module>
print(checkcompileqel())
File "/home/process_tools/testcode.py", line 10, in checkcompileqel
print(matchstart.match(lines).group(0))
AttributeError: 'NoneType' object has no attribute 'group'