self.viewerData = []
tempViewerData = []
tempViewer = []
started = False
with open("tittardata.txt", "r") as fp:
for i, line in enumerate(fp.readlines()):
if line.startswith("=="):
started = True
continue
if started and line.startswith("--"):
started = False
if started == True:
tempViewerData.append(line.rstrip("\n"))
我正在尝试从下面的 txt 文件中读取两端用“---”分隔的块。在第一个块上,分隔由不同的符号处理,以“===”开头,以“--”结尾。即将到来的块由相同的符号解析,使得提取块更加困难。这是我到目前为止的尝试,感谢所有帮助。
这是文本文件的摘录:
=================
19.37/2
19.52/2
21.07/1
21.22/1
21.37/1
-------
19.37/2
19.52/2
-------