binary data

Fredrik Lundh fredrik at pythonware.com
Thu Aug 26 12:20:25 CEST 1999


Gerhard W. Gruber <g.gruber at xsoft.co.at> wrote:
> How do I write binary data to a file?
> I'm using open() and write and I always get the error that n is an
> integer.

1. make sure to open the file in binary mode (the 'b' flag).
see:

    http://www.python.org/doc/current/lib/built-in-funcs.html

2. for different ways to convert integers to binary data, see:

    http://www.python.org/doc/current/lib/module-struct.html
    http://www.python.org/doc/current/lib/module-array.html

</F>





More information about the Python-list mailing list