Python reads binary data from a specific position

I have a huge binary file from which I want to read several bytes from the exact positions in the file. How can I access specific bytes from a binary file without linking all bytes from the beginning of the file? Thanx,

+7
source share
1 answer

Make sure you open the file with the attribute "b" (for example: file("myfile.bin", "rb") ). Then use the seek() method for the file object.

Have a look here: http://docs.python.org/release/2.4.4/lib/bltin-file-objects.html

+9
source

All Articles