title: How to convert Strings into Bytes in Python2?
body: <p>I'm trying to convert a string into bytes and those bytes must be in a string type. I know how to do that in pyhon3, it is pretty straight forward, but in python2 I'm just lost :(</p>
  
  <p>I've tried the encode() function in python2 but it doesn't seem to work, I've read there is no such thing as byte type in python2 so that maybe the case why I'm failing.</p>
  
  <p>Anyways, I wrote this code in python3 and it is working flawlessy:</p>
  
  <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; a="hey"
  &gt;&gt;&gt; b=bytes(a, 'utf-8')
  &gt;&gt;&gt; print(b)
  b'hey'
  &gt;&gt;&gt; type(b)
  &lt;class 'bytes'&gt;
  &gt;&gt;&gt; c=''
  &gt;&gt;&gt; for i in b:
  ...     c+=str(i)+" "
  ...
  &gt;&gt;&gt;
  &gt;&gt;&gt; print (c)
  104 101 121
  </code></pre>
  
  <p>Instead with python2 I've tryed, of course bytes(a, 'utf-8') but it's saying str() takes exactly one argument (2 given).
  Then I've tryed encode() and bytearray() but no luck with those either.</p>
  
  <p>If you have any hints on how to get the representing bytes <code>104 101 121</code> of <code>ehy</code> in python2, or if you know for sure that this "conversion" is not possible please let me know.</p>