read from binary file
Ivan Van Laningham
ivanlan at callware.com
Thu Jan 20 16:44:20 EST 2000
Hi All--
Stefan Andreatta wrote:
>
> I have encountered severe problems when trying to read large amounts of data
> (unsigned short integer) from a binary file under NT. I use something like:
>
> f = 'C:\\ai.xxx'
> file = open(f,'r')
file=open(f,'rb')
> buffer = file.read()
>
> But the read() function always returns just some 1000 bytes of data and the
> stops.
>
> Does anybody know, what could be the reason for that, and how I could read
> the whole file into a string?
>
You must use the binary flag ('rb' instead of 'r') on Windoze, because
it cares. Unices don't.
<tell-it-to-an-os-that-cares>-ly y'rs,
Ivan
----------------------------------------------
Ivan Van Laningham
Callware Technologies, Inc.
ivanlan at callware.com
ivanlan at home.com
http://www.pauahtun.org
See also:
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps: Cu Chi, Class of '70
Author: Teach Yourself Python in 24 Hours
----------------------------------------------
More information about the Python-list
mailing list