stripping the first byte from a binary file

Jeremy Sanders jeremy+complangpython at jeremysanders.net
Tue Jul 10 12:37:02 CEST 2007


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')
f.read(1)  # read 1st byte and ignore it
rest = f.read()  # read rest

or

data = f.read()
data = data[1:] # skip 1st byte

?

-- 
Jeremy Sanders
http://www.jeremysanders.net/



More information about the Python-list mailing list