theta sigma
1 0.1
2 0.1
3 0.2
...
END
some text...
theta sigma
1 0.3
2 0.2
...
END
more data...
我想在每个“结束”之后生成一个新文件来分别分析数据。我尝试了其他答案的一些解决方案,比如
with open('fort.16', 'r') as infile, open('output_fort.16', 'w') as outfile:
copy= False
for line in infile:
if line.strip() == '# legend':
copy = True
continue
elif line.strip()=='End':
copy = False
elif copy:
outfile.write(line)
但这不是我需要的。
我对python还不太熟悉,所以非常感谢您的帮助。