[Tutor] convert ascii to binary

Joel Goldstick joel.goldstick at gmail.com
Wed Sep 12 13:54:05 CEST 2012

On Wed, Sep 12, 2012 at 7:20 AM, Aaron Pilgrim <aaronpil at gmail.com> wrote:
> Hello,
> I am trying to write a small program that converts ascii to binary.
> I tried using the python reference library section 18.8 but had
> trouble understanding how to make it work.
>  Here is the code I am currently trying to use:
> def main():
>         import binascii
>         myWord = input("Enter the word to convert..")
>         #convert text to ascii
>         for ch in myWord:
>                 print(ord(ch))
>                 #convert ascii to binary
>                 binascii.a2b_uu(ord(ch))
> main()
A couple of thoughts.  The section you reference suggests using higher
level modules such as uu.
uu seems to want to read an ascii file and write a uu encoded file.

I just read the wikipedia article on uuencoding, since I have heard of
it, but never needed to know about it.  It is apparently a pretty old
method of transforming 3 consecutive 8 bit ascii characters into 4 6
bit uuencoded characters so that they can be sent between (unix)

What are you really trying to do?  Is this for experimenting with
python? or are you trying to solve some larger problem?

Joel Goldstick

More information about the Tutor mailing list