Larry <[EMAIL PROTECTED]> writes: > My data is a = [23, 45, 56, 255]. > My desire output is: 234556255, of course in binary file > representation already. > > I tried to make one using write after pack method of struct module, > but because of spaces I got incorrect results.
struct.pack works for me: Python 2.4.4 (#1, Oct 23 2006, 13:58:00) >>> import struct, os >>> x = struct.pack('BBBB', 23, 45, 56, 255) >>> len(x) 4 >>> f = open('/tmp/foo','w'); f.write(x); f.close() >>> os.system("ls -l /tmp/foo") -rw------- 1 phr phr 4 Mar 17 01:27 /tmp/foo >>> You could also do the list-string conversion with the array module. -- http://mail.python.org/mailman/listinfo/python-list