12

I have a huge binary file from which I want to read some bytes from exact positions in the file. How can I access specific bytes from binary file not having to loop through all bytes from the beginning of the file? Thanx,

1 Answer 1

14

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

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.