Reading binary files

Ronn Ross ronn.ross at
Mon Aug 24 18:50:37 CEST 2009

On Mon, Aug 24, 2009 at 11:18 AM, Ronn Ross <ronn.ross at> wrote:

> On Mon, Aug 24, 2009 at 10:43 AM, Albert Hopkins <marduk at>wrote:
>> On Mon, 2009-08-24 at 10:35 -0400, Ronn Ross wrote:
>> > I need to read a binary file. When I open it up in a text editor it is
>> > just junk. Does Python have a class to help with this?
>> Yes, the "file" class.
>> >>> myfile = open('/path/to/binary/file', 'rb')
>> -a
> This works for a simple binary file, but the actual file I'm trying to read
> is give throwing an error that the file cannot be found. Here is the name of
> the my file:
> 2009.08.02_06.52.00_WA-1_0001_00_0662_0.jstars
> Should python have trouble reading this file name or extension?
I'm having trouble with the filename:

It throws an error with that file name, When I change it to something like
sample.txt it runs, but the data is still garbled. Is there any reason why I
can't use the above file name? If I'm using 'rb' to read the binary file why
is it still garbled?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list