Scanning a file

Paul Rubin http
Fri Oct 28 07:29:47 EDT 2005


pinkfloydhomer at gmail.com writes:
> I want to scan a file byte for byte for occurences of the the four byte
> pattern 0x00000100. I've tried with this:

use re.search or string.find.  The simplest way is just read the whole
file into memory first.  If the file is too big, you have to read it in
chunks and include some hair to notice if the four byte pattern straddles
two adjoining chunks.



More information about the Python-list mailing list