struct unpack newline
Peter Otten
__peter__ at web.de
Tue May 31 02:54:11 EDT 2005
grant at idscape.co.za wrote:
> what concerns me though is that although the file is opened in binary
> mode,
> "for line.." has a problem reading the file correctly.
There is _no_ correct way of splitting a file containing binary data in
lines because binary data may contain newline bytes that do not indicate a
new line. E. g.
>>> struct.unpack("l", "\r\n\r\n")
(168626701,)
how should Python know whether it just encountered two empty lines or the
integer 168626701?
Peter
More information about the Python-list
mailing list