Fw: reading binary data

Ken Seehof kens at sightreader.com
Wed Mar 14 21:41:45 CET 2001


----- Original Message -----
From: "Ken Seehof" <kens at sightreader.com>
To: "Francois Forest" <francois_forest at yahoo.fr>
Sent: Wednesday, March 14, 2001 2:37 PM
Subject: Re: reading binary data


> Take a look at the "struct" module.  It has all you need to mess around
with
> binary data.  I have an interactive tool (called filecracker) for reverse
> engineering binary files using the struct module, but I haven't found time
> to release it yet.  If you want, I can email it to you (if enough people
> respond to this, I'll be motivated to post it in parnassus).
>
> BTW, there's a gotcha, that everyone learns the hard way early on.  Make
> sure you use the 'b' flag when opening binary files.
>
> f = open('ni.wav', 'rb')
>
> If you don't, the file will be truncated at the first ascii end-of-file
> marker that happens to be in the binary data.
>
> ----- Original Message -----
> From: "Francois Forest" <francois_forest at yahoo.fr>
> Newsgroups: comp.lang.python
> To: <python-list at python.org>
> Sent: Wednesday, March 14, 2001 3:46 PM
> Subject: reading binary data
>
>
> > I would like to read and write xxx.wav files,
> > this assume to alternatively read characters,  integers 16 bits and
> > integers 32 bits.
> > I found that I can read a binary file and get the result in a string,
> > Is there a way to convert a string slice into an int16, int32, or
> > floatting point ?
> > (what is usually done in C through a cast).
> >
> > More generally, how can I browse through standard libraries ?
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
>





More information about the Python-list mailing list