Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I wanted read a image using PIL.Image.open().But I've image in different path. The following is the path I've the python script

"D:YY_Aadhiholy-edge-masterhed	est.py"

The following is the path I've the image file.

"D:YY_AadhiHED-BSDS	est2018.jpg"

from PIL import Image
'''some code here'''
image = Image.open(????)

How should I fill the question mark to access the image file.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
170 views
Welcome To Ask or Share your Answers For Others

1 Answer

you can simply do

from PIL import Image
image = Image.open("D:\YY_Aadhi\HED-BSDS\test\2018.jpg")

or

from PIL import Image
directory = "D:\YY_Aadhi\HED-BSDS\test\2018.jpg"
image = Image.open(directory)

like this.

you have to write escape sequence twice in windows, when you want to define as directory. and It will be great if you try some stupid code. It helps you a lot.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...