Reading file bit by bit

Ulrich Eckhardt eckhardt at satorlaser.com
Mon Jun 7 06:20:11 EDT 2010


Ulrich Eckhardt wrote:
>    data = f.read()
>    for byte in data:
>        for i in range(8):
>            bit = 2**i & byte
>            ...

Correction: Of course you have to use ord() to get from the single-element
string ("byte" above) to its integral value first.

Uli

-- 
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932




More information about the Python-list mailing list