read only the last x bytes from a text file

Raymond Hettinger python at rcn.com
Wed May 29 09:32:34 EDT 2002


"Felix Seeger" <seeger at sitewaerts.de> wrote
> Hi

Hello!

>
> I am writing a log monitor.
> It checks the filesize and the new filesize.
>
> Now I want only the difference between this vars.
> eg read the last 1000 bytes from the file.
>
> How can I do this ?

f = open('myfile')
f.seek(-1000, 2)
s = f.read(1000)


Raymond Hettinger







More information about the Python-list mailing list