title: Binary to String/Text in Python
body: <p>I have searched many times online and I have not been able to find a way to convert my binary string variable, <strong><em>X</em></strong></p>
  
  <pre><code>X = "1000100100010110001101000001101010110011001010100"
  </code></pre>
  
  <p>into a UTF-8 string value.</p>
  
  <p>I have found that some people are using methods such as</p>
  
  <pre><code>b'message'.decode('utf-8')
  </code></pre>
  
  <p>however, this method has not worked for me, as 'b' is said to be nonexistent, and I am not sure how to replace the 'message' with a variable. Not only, but I have not been able to comprehend how this method works. Is there a better alternative?</p>
  
  <p>So how could I convert a binary string into a text string?</p>
  
  <p>EDIT: I also do not mind ASCII decoding</p>
  
  <p>CLARIFICATION: Here is specifically what I would like to happen.</p>
  
  <pre><code>def binaryToText(z):
      # Some code to convert binary to text
      return (something here);
  X="0110100001101001"
  print binaryToText(X)
  </code></pre>
  
  <p>This would then yield the string...</p>
  
  <pre><code>hi
  </code></pre>