On Tue, Jun 16, 2009 at 12:46 PM, <[email protected]> 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 - [email protected]
http://mail.python.org/mailman/listinfo/tutor