stripping the first byte from a binary file

rvr rvanroode at
Wed Jul 11 03:06:04 CEST 2007

On Jul 10, 6:37 pm, Jeremy Sanders <jeremy
+complangpyt... at> wrote:
> rvr wrote:
> > Would someone mind showing me how to strip the first byte from a
> > binary file? For some reason I can't figure this out from the binary
> > file editing examples I've read. Thanks.
> Do you mean something like this?
> f = open('test.dat', 'rb')
>  # read 1st byte and ignore it
> rest =  # read rest
> or
> data =
> data = data[1:] # skip 1st byte

Is there a way to edit the file in place? The best I seem to be able
to do is to use your second solution to read the file into the string,
then re-open the file for writing and put the whole thing back (minus
the first byte). Thanks.


More information about the Python-list mailing list