title: Read string from binary file
body: <p>I want to read bytes 1,2 and 3 from a file. I know it corresponds to a string (in this case it's <code>ELF</code> of a Linux binary header)</p>
  
  <p>Following examples I could find on the net I came up with this:</p>
  
  <pre><code>with open('hello', 'rb') as f:
      f.seek(1)
      bytes = f.read(3)
      string = struct.unpack('s', bytes)
      print st
  </code></pre>
  
  <p>Looking at the official documentation of <a href="https://docs.python.org/2.7/library/struct.html" rel="nofollow">struct</a> it seems that passing <code>s</code> as argument should allow me to read a string.</p>
  
  <p>I get the error:</p>
  
  <pre><code>st = struct.unpack('s', bytes)
  struct.error: unpack requires a string argument of length 1
  </code></pre>
  
  <p>EDIT: Using Python 2.7</p>