import re a=0xf27f28d7 b=a.to_bytes(4, \'little\') with open(fimage, \'rb\') as f: [hex(m.start(0)] for m in re,finditer(b, f.read())