0

I want to read all the image names from a directory. I am using the code given below but not getting the answer.

from PIL import Image
import glob
image_list = []
for filename in 
 glob.glob('D:\Rese\OneShot\OneShot\all_runs\run02\test\*.PNG'): #assuminggif
im=Image.open(filename)
image_list.append(im)

print image_list 

this piece of code only returns the Empty list althought there are multiple images in the directory.

abarnert
  • 354,177
  • 51
  • 601
  • 671
  • Indentation is important in python, can you fix your indentation. Have you tried printing out the filenames, to ensure `glob` is returning something? – AChampion Jul 17 '18 at 04:19
  • Try `print 'OneShot\all_runs'` on your interactive terminal, then look at the table under [String literals](https://docs.python.org/2/reference/lexical_analysis.html#string-literals). – abarnert Jul 17 '18 at 04:22
  • As a side note, your comment says `#assuminggif`, but your glob says `*.PNG`. Those are two pretty different file formats. – abarnert Jul 17 '18 at 04:23

0 Answers0