A Cool Quick Find in Python

I have been looking for a way to read a string as a file in Python for a while. Basically, I want to be able to read images without first saving them, like with sometimes using Java’s .getBytes() method for strings combined with the ByteArrayInputStream  when offered the use of a stream input by an API method as a method parameter. The answer, BytesIO. This amazing class works wonders.

from io import BytesIO
from PIL import Image

Leave a Reply