我的数据文件结构如下:
handle:trial1
key_left:3172
key_up:
xcoords:12,12,12,15........
ycoords:200,200,206,210,210......
t:20,140,270,390.....
goalx:2
goaly:12
fractal:images/file.png
seen:true
pauseTimes:
fractal:images/file2.png
seen:False
pauseTimes:
...
...
我只想提取goaly
行之后直到pauseTimes
行的信息。如果我知道所有试验的goaly
值,我可以指定那一行并提取goaly:
和pauseTimes
之间的数据,但是我不会提前知道任何goaly
的值是什么,因为它们是动态生成的。你知道吗
如何使用字符串"goaly"
标识该行,然后提取所有后续行直到pauseTimes
行?你知道吗
不管是否关心行,都可以使用状态变量进行循环和跟踪。我喜欢用生成器跟踪这样的解析状态,使其与处理代码分离。例如,以下是生成器:
下面是您如何使用它:
还有一个额外的功能,就是跟踪你正在进行的审判。你知道吗
相关问题 更多 >
编程相关推荐