read string in bits

Hendrik van Rooyen mail at
Wed Jan 14 09:15:42 CET 2009

 "Chris Rebert" <clp2 at> wrote:

> It's not quite clear to me what you mean, but here are 2 guesses:
> - If you want to convert an ASCII character to its ASCII integer
> value, use ord()
> - If you want to convert an integer into a string of its base-2
> representation, use bin() [requires Python 2.6, I think]

Another case:

>>> s = '1010101'
>>> int (s,2)

Works almost anywhere, AFAIK.

- Hendrik

More information about the Python-list mailing list