<wallenpb <at> gmail.com> writes: > > self.out.write(b'BM') worked beautifully. Now I also have a similar > issue, for instance: > self.out.write("%c" % y) is also giving me the same error as the other > statement did. > I tried self.out.write(bytes("%c" %y),encoding=utf-8) in an attempt to > convert to bytes, which it did, but not binary. How do I affect > self.out.write("%c" % y) to write out as a binary byte steam? I also > tried self.out.write(b"%c" % y), but b was an illegal operator in when > used that way. > It is also supposed to be data being written to the .bmp file. --Bill
Are you writing to sys.stdout? If so, use sys.stdout.buffer.write(b'some bytes'). If you're writing to a file, you have to open it in binary mode like this: open("someimage.bmp", "wb") -- http://mail.python.org/mailman/listinfo/python-list