[Python3] Reading a binary file and wrtiting the bytes verbatim in an utf-8 file
clp2 at rebertia.com
Fri Apr 23 12:50:27 EDT 2010
On Fri, Apr 23, 2010 at 9:48 AM, Chris Rebert <clp2 at rebertia.com> wrote:
> On Fri, Apr 23, 2010 at 9:22 AM, <fab at slick.airforce-one.org> wrote:
>> I have to read the contents of a binary file (a PNG file exactly), and
>> dump it into an RTF file.
>> how can I tell python to dump the bytes as they are, without
>> interpreting them?
> Go around the encoder and write bytes directly to the file:
> # Disclaimer: Completely untested
> encoded_rtf.write(u"whatever text we want") # use unicode
Erm, sorry, since you're apparently using Python 3.x, that line should
have been just:
encoded_rtf.write("whatever text we want") # use unicode
More information about the Python-list