We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 455a113 + 1f58028 commit 8e33285Copy full SHA for 8e33285
1 file changed
docs/handbook/tutorial.rst
@@ -464,17 +464,17 @@ Reading from an open file
464
with open("hopper.ppm", "rb") as fp:
465
im = Image.open(fp)
466
467
-To read an image from string data, use the :py:class:`~StringIO.StringIO`
+To read an image from binary data, use the :py:class:`~io.BytesIO`
468
class:
469
470
-Reading from a string
471
-^^^^^^^^^^^^^^^^^^^^^
+Reading from binary data
+^^^^^^^^^^^^^^^^^^^^^^^^
472
473
::
474
475
from PIL import Image
476
- import StringIO
477
- im = Image.open(StringIO.StringIO(buffer))
+ import io
+ im = Image.open(io.BytesIO(buffer))
478
479
Note that the library rewinds the file (using ``seek(0)``) before reading the
480
image header. In addition, seek will also be used when the image data is read
0 commit comments