开发者

copy lines in range using Python/Jython

I have a server log file which is constantly updated. after some script execution, I want to collect the relevant part of my execution from the server log into an execution log.

Basically, I need to c开发者_开发问答apture the last line number of my server log before the test started (which I already know how to do), say X, and after execution, copy the lines from X to the new end of server log, now, X+1000.

How do I copy only lines X to X+1000?

Thanks, Assaf


Try this

open("execution.log", "w").write("\n".join(open("server.log").readlines()[X:X+1000]))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜