error writing str to binary stream - fails in Python 3.0.1, works in 2.x
Terry Reedy
tjreedy at udel.edu
Mon Mar 16 17:42:56 EDT 2009
wallenpb at gmail.com wrote:
> Thanks for the assist. One more question, please.
>
> 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.
If you actually wrote that, try
self.out.write(bytes("%c" %y,encoding=utf-8))
To aid respondents, copy an paste actually code run and actual result or
traceback received.
tjr
More information about the Python-list
mailing list