title: How do I convert a string 2 bytes long to an integer in python
body: <p>I have a python program I've inherited and am trying to extend.</p>
  
  <p>I have extracted a two byte long string into a string called pS.</p>
  
  <p>pS 1st byte is 0x01, the second is 0x20, decimal value == 288</p>
  
  <p>I've been trying to get its value as an integer, I've used lines of the form</p>
  
  <pre><code>x = int(pS[0:2], 16)  # this was fat fingered a while back and read [0:3]
  </code></pre>
  
  <p>and get the message</p>
  
  <pre><code>ValueError: invalid literal for int() with base 16: '\x01 '
  </code></pre>
  
  <p>Another C programmer and I have been googling and trying to get this to work all day.</p>
  
  <p>Suggestions, please.</p>