read n bytes from a binary file
sismex01 at hebmex.com
sismex01 at hebmex.com
Fri Nov 15 17:39:19 EST 2002
> From: Rajarshi Guha [mailto:rajarshi at presidency.com]
> Sent: Friday, November 15, 2002 4:32 PM
>
> Hi,
> I have a simple question, but I cant seem to find the function to do
> it!
> How can I read N bytes from a file opened in binary mode.
> Basically I'm trying to check that a PDF file is indeed a PDF file
>
> thanks,
>
too simple...
>>> f = file("BTB.zip","rb")
>>> f.read(8)
'PK\x03\x04\x14\x00\x02\x00'
>>>
HTH!
-gustavo
More information about the Python-list
mailing list