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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s