Changed tutorial code to use with for opening files [ci skip]

This commit is contained in:
Andrew Murray 2017-05-29 19:41:48 +10:00
parent cafc311943
commit 5eabd731f0

View File

@ -476,8 +476,8 @@ Reading from an open file
::
from PIL import Image
fp = open("hopper.ppm", "rb")
im = Image.open(fp)
with open("hopper.ppm", "rb") as fp:
im = Image.open(fp)
To read an image from string data, use the :py:class:`~StringIO.StringIO`
class: