Binary file output using python

kyosohma at kyosohma at
Tue Apr 17 20:07:38 CEST 2007

On Apr 17, 12:41 pm, Chi Yin Cheung <c-che... at> wrote:
> Hi,
> Is there a way in python to output binary files? I need to python to
> write out a stream of 5 million floating point numbers, separated by
> some separator, but it seems that all python supports natively is string
> information output, which is extremely space inefficient.
> I'd tried using the pickle module, but it crashed whenever I tried using
> it due to the large amount of data involved.
> Thanks for your help!

You can create a binary file by doing something like this:

f = open(r'filename, 'b')

See also:

Have fun!


More information about the Python-list mailing list