[Tutor] convert ascii to binary
d at davea.name
Wed Sep 12 14:31:12 CEST 2012
On 09/12/2012 07:20 AM, Aaron Pilgrim wrote:
> 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.
If you supplied a link, we might be able to figure out what section 10.8
is. It'll vary between versions of Python. And in version 2.7, there
doesn't seem to be a section 10.8
It would also be useful to specify the version of Python that this is
for. But on the assumption that it's either 2.6 or 2.7, try the
if that's not what you want, then you'd better give us some sample input
and output, or give the usage context or quote the assigmment.
> 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:
> #convert ascii to binary
That function converts a line of uuencoded data to the binary data that
generated it. Your ch isn't a line of uuencoded data, and you don't do
anything with the return value. Besides, your subject line implies you
want the reverse order.
More information about the Tutor