Thanks for the reply I would like to print the string in binary 
Man=010011010110000101101110
Sent from my Verizon Wireless BlackBerry

-----Original Message-----
From: Wayne <sri...@gmail.com>

Date: Tue, 16 Jun 2009 13:13:58 
To: <xchime...@gmail.com>
Cc: <tutor@python.org>
Subject: Re: [Tutor] Conversion question


On Tue, Jun 16, 2009 at 12:46 PM, <xchime...@gmail.com> wrote:

> Quick question.  Say I have a string a="Man" and I want to print the string
> in base2.  Is there a python function like there is in perl to do this?
> Thanks in advance for any input


do you mean like this:

 In [23]: int('Man', 2)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)

/home/wayne/<ipython console> in <module>()

ValueError: invalid literal for int() with base 2: 'Man'

Or do you mean this?
In [24]: mystr = 'some string'

In [25]: mystr.encode('hex')
Out[25]: '736f6d6520737472696e67'

HTH,
Wayne



-- 
To be considered stupid and to be told so is more painful than being called
gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness,
every vice, has found its defenders, its rhetoric, its ennoblement and
exaltation, but stupidity hasn’t. - Primo Levi

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to