[Tutor] Opening C++ binary files
steve at pearwood.info
Wed Sep 22 00:11:54 CEST 2010
On Wed, 22 Sep 2010 02:03:41 am Joe Bennett wrote:
> I have some binary files created by a program written in C++...
> Anyone have any experience with this and willing to share? ACSII test
> is easy, but not sure how the rest is encoded....????
What difference does the language the program was written in make? What
matters is the *type* of binary file: .avi, .mp3, .jpg, .png, .doc,
.zip, or any one of a million other kinds of binary file.
If the binary file is a standard data type, like .mp3 or .zip, your best
strategy is to find a library specially desigined for that data type,
and use it.
If it's a non-standard type, you can open and read the file yourself
f = open("name-of-binary-file", "rb") # you MUST have the b
data = f.read()
and then do whatever you want with the data. The struct module may be
useful for that.
If you don't know what the structure of the data is, then there's
probably not much you can do with it except make a mess.
More information about the Tutor