Ascii to binary conversion

Terry Reedy tjreedy at udel.edu
Sat Aug 9 17:49:09 EDT 2008



azrael wrote:

> Any idea how to easily write a function that recieves a character or
> string and returns a binary number like:
> ascii("1") is converted to bin("00110001")

Other alternatives in 2.6 (I believe) and 3.0:
 >>> 0b00111010101
469
 >>> b='111010101'
 >>> eval('0b'+b)
469
 >>> '{0:b}'.format(469)
'111010101'




More information about the Python-list mailing list