Editing a Binary File.
exarkun at intarweb.us
Mon Jun 9 08:45:21 CEST 2003
On Sun, Jun 08, 2003 at 11:37:24PM -0700, Paradox wrote:
> I need to edit a few bytes in an existing binary file. Is this
> possible with the Python file object or if not what is another way
> that I can accomplish this?
> I am running Python 2.2 under Windows.
> I have tried using open(fileName, 'a+b') and open(fileName, 'w+b').
> With a+ I have not been able to write anywhere but to the end of the
> file and with w+ it destroys my file.
Try the mode 'r+b', I think you will find it to your liking.
Where a calculator on the ENIAC is equipped with 18,000 vacuum tubes and
weighs 30 tons, computers in the future may have only 1,000 vacuum tubes and
weigh only 1.5 tons. -- Popular Mechanics, March 1949
More information about the Python-list