title: Convert Bytes into BufferedReader object in Python?
body: <p>The title of this question is the same as <a href="https://stackoverflow.com/q/47198948/3552975">this one</a>, and I have voted to reopoen the question.</p>
  <p>I want to convert a byte object into a BufferedReader one, and here is my attempts(after referring to many articles):</p>
  <pre><code>import numpy as np
  from PIL import Image as PILImage
  from io import BytesIO
  img_np = np.asarray([[[16, 16, 16], [2, 2, 2], [0, 0, 0], [6, 6, 6], [8, 8, 8], [0, 0, 0], [21, 21, 21], [3, 3, 3], [0, 0, 0], [62, 62, 62]], [[0, 0, 0], [71, 71, 71], [142, 142, 142], [107, 107, 107], [99, 99, 99], [101, 101, 101], [4, 4, 4], [86, 86, 86], [99, 99, 99], [146, 146, 146]], [[162, 162, 162], [203, 203, 203], [192, 192, 192], [228, 228, 228], [191, 191, 191], [178, 178, 178], [222, 222, 222], [200, 200, 200], [198, 198, 198], [182, 182, 182]], [[117, 117, 117], [178, 178, 178], [199, 199, 199], [214, 214, 214], [222, 222, 222], [208, 208, 208], [255, 255, 255], [251, 251, 251], [219, 219, 219], [255, 255, 255]], [[0, 0, 0], [0, 0, 0], [80, 80, 80], [169, 169, 169], [193, 193, 193], [238, 238, 238], [239, 239, 239], [243, 243, 243], [254, 254, 254], [230, 230, 230]], [[20, 20, 20], [20, 20, 20], [9, 9, 9], [1, 1, 1], [130, 130, 130], [194, 194, 194], [216, 216, 216], [255, 255, 255], [252, 252, 252], [255, 255, 255]], [[9, 9, 9], [0, 0, 0], [0, 0, 0], [0, 0, 0], [3, 3, 3], [44, 44, 44], [191, 191, 191], [217, 217, 217], [248, 248, 248], [225, 225, 225]], [[0, 0, 0], [11, 11, 11], [3, 3, 3], [11, 11, 11], [6, 6, 6], [15, 15, 15], [0, 0, 0], [153, 153, 153], [255, 255, 255], [253, 253, 253]], [[0, 0, 0], [5, 5, 5], [1, 1, 1], [4, 4, 4], [8, 8, 8], [4, 4, 4], [3, 3, 3], [0, 0, 0], [159, 159, 159], [241, 241, 241]], [[10, 10, 10], [9, 9, 9], [6, 6, 6], [2, 2, 2], [0, 0, 0], [0, 0, 0], [3, 3, 3], [20, 20, 20], [0, 0, 0], [185, 185, 185]]])
  im = PILImage.fromarray(img_np.astype(np.uint8))
  # im.save('./temp.jpeg', &quot;JPEG&quot;)
  # f = open('./temp.jpeg', 'rb')
  # print(type(f))
  
  #
  b_handle = io.BytesIO()
  im.save(b_handle, format=&quot;JPEG&quot;)
  # b = im.tobytes()
  print(type(b_handle))
  b = b_handle.read()
  print(type(b))
  print(b)
  
  im.save(b_handle, format=&quot;JPEG&quot;)
  b_br = io.BufferedReader(b_handle)
  print(type(b_br))
  b = b_br.read()
  print(type(b))
  print(b)
  </code></pre>
  <p>The output is as below:</p>
  <pre><code>&lt;class '_io.BytesIO'&gt;
  &lt;class 'bytes'&gt;
  b''
  &lt;class '_io.BufferedReader'&gt;
  &lt;class 'bytes'&gt;
  b''
  </code></pre>
  <p>It seems that the file like objects are empty. I know that for the <code>b_handle</code> I can get the value by <code>b_handle.getvalue()</code> but for the bufferedreader it doesn't work as a file object.</p>
  <p>How can I convert a byte string into a bufferedreader object, the same as I open a file?</p>