title: Converting string which contains bytearray to uint16
body: <p>I have a large bytearray which I store to a file, for post-processing purposes. For this example, let's assume the data is a counter from 0 to 3 base 10. </p>
  
  <p>The format I retrieve the data in from a certain method is a bytearray, and I need to store it efficiently as the simulation requires a large data-set. Therefore I store it as </p>
  
  <pre><code>f=open('data_0.txt','w')
  f.write(str(b_a))
  f.close()
  </code></pre>
  
  <p>when I read it I get a string of data: <code>data_read =  b'\x00\x00\x01\x00\x02\x00\x03\x00'</code></p>
  
  <pre><code>f=open('data_0.txt')
  data_read = f.read()
  f.close()
  </code></pre>
  
  <p>I expect a function to take the string: <code>b'\x00\x00\x01\x00\x02\x00\x03\x00'</code> and convert it to an array of <code>[0, 1, 2, 3]</code>. </p>
  
  <p>When I use <code>struct.unpack("BBBBBBBB" , data_read)</code> I would expect <code>0,0,1,0,2,0,3,0</code>, instead it just displays the ascii for b,',\,x, etc., it is the same for <code>ord(0)</code>, <code>ord(1)</code> etc.</p>
  
  <p>Is there any convenient function or pythonic manner to go from a string:  <code>b'\x00\x00\x01\x00\x02\x00\x03\x00'</code> and convert it to an array of <code>[0, 1, 2, 3]</code>?   </p>