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]))
精彩评论