Øyvind wrote:
> Hello.
> 
> Is it possible to read the bits (the 0's and 1's) of a string or a file
> with Python? What module would I use?

I don't know exactly what you mean by "read the bits" but you can use
data = open('afile', 'b').read() to get the data into a string
byte1=ord(data[1]) to get a character as binary data
byte1 & 1 to extract a single bit

You might also be interested in the struct module which lets you extract 
larger data (e.g. ints and floats) from a string.

Kent

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to