read string in bits
Hendrik van Rooyen
mail at microcorp.co.za
Wed Jan 14 09:15:42 CET 2009
"Chris Rebert" <clp2 at rebertia.com> 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]
>>> s = '1010101'
>>> int (s,2)
Works almost anywhere, AFAIK.
More information about the Python-list