0

We had DataInputStream for processing binary files in Java; what can we use for these files in Python?

2

3 Answers 3

2

I have used the Construct package a lot to read and parse structures data in Python.

Basically it lets you declare the file's structure in a very idiomatic and pythonic way and than parses or encode it for you.

After parsing you have an object that allows access to all the file's information via attributes.

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

Comments

1

open("file", "b") opens the file and you can read it. See here.

Comments

1

Few years ago I used struct module to parse binary responses from several game servers http://docs.python.org/2/library/struct.html#struct.unpack

Sometimes it's usefull just to .find() some bytes in data, like .find('\x00') to go to the end of NULL-terminated string.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.