[Tutor] string to binary and back... Python 3

Jordan wolfrage8765 at gmail.com
Thu Jul 19 20:33:39 CEST 2012



On 07/19/2012 12:15 AM, Prasad, Ramit wrote:
<SNIP>
> I think your basic problem is too much conversion because you do not
> understand the types. A string is represented by a series of bytes
> which are binary numbers. Do you understand the concept behind ASCII?
> Each letter has a numeric representation that are sequential. So the
> string 'abcd' is equivalent to a series of bytes 65,66,67,68. It is
> not equivalent to 65666768 or 65+66+67+68. So your first task is to
> convert each character to the numeric equivalent and store them in a
> list. Once you have them converted to a list of integers, you can
> create another list that is a list of characters.
Sorry for the long delay in getting back to you, I got called to the field.
Thank you, I agree I do feel like I am doing too much conversion. I do
understand the concept behind ASCII at least enough to know about ord()
although I did for get about chr() which is ord()'s reverse function. I
had tried to break them down to the ordinal value, but I really do want
to get the integer and the data down to binary, as it provides an
advantage for the overall program that I am writing. Thank you for your
time.
>
> Look at the functions chr and ord here
> ( http://docs.python.org/py3k/library/functions.html )
>
> Ramit
>
>
> Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
> 712 Main Street | Houston, TX 77002
> work phone: 713 - 216 - 5423
>
> --
>
> This email is confidential and subject to important disclaimers and
> conditions including on offers for the purchase or sale of
> securities, accuracy and completeness of information, viruses,
> confidentiality, legal privilege, and legal entity disclaimers,
> available at http://www.jpmorgan.com/pages/disclosures/email.  
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor


More information about the Tutor mailing list