On 03/09/2015 08:45 PM, Paulo da Silva wrote:
Hi!

What is the best way to read a file that begins with some few text lines
and whose rest is a binary stream?

As an exmaple ... files .pnm.

Thanks for any comments/help on this.


In which version of Python?  there's a huge difference between 2.x and 3.x

Generally speaking, you can treat a piece of a binary (input) file as an encoded string, so you want to open the file as binary, locate the part that's text, and then explicitly decode the string from that.


--
DaveA
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to