title: How can I convert bytes object to decimal or binary representation in python?
body: <p>I wanted to convert an object of type bytes to binary representation in python 3.x.</p>
  
  <p>For example, I want to convert the bytes object <code>b'\x11'</code> to the binary representation <code>00010001</code> in binary (or 17 in decimal).</p>
  
  <p>I tried this:</p>
  
  <pre><code>print(struct.unpack("h","\x11"))
  </code></pre>
  
  <p>But I'm getting:</p>
  
  <pre><code>error struct.error: unpack requires a bytes object of length 2
  </code></pre>