<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv="Content-Type" content="text/html; charset=utf-8"> </HEAD>Thanks for the reply I would like to print the string in binary Man=010011010110000101101110<p>Sent from my Verizon Wireless BlackBerry</p><p><hr size=2 width=100% align=center tabindex=-1><b>From</b>:  Wayne <srilyk@gmail.com><br><b>Date</b>: Tue, 16 Jun 2009 13:13:58 -0500<br><b>To</b>: &lt;xchimeras@gmail.com&gt;<br><b>Subject</b>: Re: [Tutor] Conversion question<br></font></p><div class="gmail_quote">On Tue, Jun 16, 2009 at 12:46 PM,  <span dir="ltr">&lt;<a href="mailto:xchimeras@gmail.com">xchimeras@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">  Quick question.  Say I have a string a=&quot;Man&quot; and I want to print the string in base2.  Is there a python function like there is in perl to do this?<br> Thanks in advance for any input</blockquote><div><br>do you mean like this:<br><br> In [23]: int(&#39;Man&#39;, 2)<br>---------------------------------------------------------------------------<br>ValueError                                Traceback (most recent call last)<br> <br>/home/wayne/&lt;ipython console&gt; in &lt;module&gt;()<br><br>ValueError: invalid literal for int() with base 2: &#39;Man&#39;<br><br>Or do you mean this?<br>In [24]: mystr = &#39;some string&#39;<br><br>In [25]: mystr.encode(&#39;hex&#39;)<br>  Out[25]: &#39;736f6d6520737472696e67&#39;<br><br>HTH,<br>Wayne<br></div></div><br><br clear="all"><br>-- <br>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<br>    --0016368e1c09ac3cfe046c7b244a--</html>