[Tutor] Writing BINARY-CONTENT
dieck.s at dsoftware.de
Mon Nov 24 03:45:38 EST 2003
>> a = open('c:\\test.me', 'wb') # opens a file for binary writing
>This is correct for writing binary. Are you sure that the program or
>you're using to check this isn't opening the file in text mode (with 'r'
>instead of 'rb')?
Yes I'm sure to open in binary mode
There is a huge problem around this:
If I want write 256 "different" bytes. Python put 257 bytes to the File.
On reading, the lenght is 256 bytes to work with. (-1)
It seems like the size I expect, but the file on the disk has more bytes.
(not really good for binaries)
But such a behavior can corrupt my data.
Isn't there a better or a fixed method to open and handle binaries?
More information about the Tutor