En Fri, 13 Jul 2007 11:53:41 -0300, Robert Dailey <[EMAIL PROTECTED]>  
escribió:

> However, I found it isn't possible since Python
> mainly works with strings in file data instead of bytes. To write a
> number 400000 to a file in python would take 6 bytes instead of 4, for
> example.

py> import struct
py> f = open("output.bin","wb")
py> f.write(struct.pack("l", 400000))
py> f.close()
py> ^Z


C:\TEMP>dir output.bin
  El volumen de la unidad C no tiene etiqueta.
  El número de serie del volumen es: 3828-F1AF

  Directorio de C:\TEMP

14/07/2007  00:13                 4 output.bin
                1 archivos              4 bytes
                0 dirs  18.806.763.520 bytes libres

"strings" are "strings of bytes" in Python. (If you are mostly concerned  
with characters, use unicode objects).

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to