python - Letter to Binary -
i'm new python 2.7.10. i'm trying convert not letters binary whole word itself.
a = '01100001', b = '01100010', c = '01100011'
if typed "a" output "01100001" i'm trying when typed "abcba" should print related "01100001 01100010 01100011 01100010 01100001"
is possible?
try using ord
ascii value of character, bin
convert number string of binary representation , join
concatenate output:
>>> myinput = "abcba" >>> print " ".join(bin(ord(character))[2:] character in myinput) 1100001 1100010 1100011 1100010 1100001
Comments
Post a Comment