Creating binary files

Anders M Eriksson anders.eriksson at morateknikutveckling.se
Wed May 24 09:13:49 EDT 2000


Hello!

I'm feeling more than a bit stupid for asking this but I'm stumped.

How do I create a binary file and write to it?

I need to create an binary file to store a large number of integers in
The file HAS to be binary since it's going to be read by an another
program which isn't in Python.

I know how to open a binary file

bfile = open("bfile","wb")

but how do I write an integer into the file?

n = 1066
b.write(n)	# this will not work!
b.write(repr(n))	# will not write binary


// Anders




More information about the Python-list mailing list