Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
print
#1
Trying this
from PIL import Image
import os, os.path

imgs = []
path = "c/users/anybloodyid/pictures/"
valid_images = [".jpg",".gif",".png",".tga"]
for f in os.listdir(path):
    ext = os.path.splitext(f)[1]
    if ext.lower() not in valid_images:
        continue
    imgs.append(Image.open(os.path.join(path,f))
	print (imgs)
keep getting this
    print (imgs)
        ^
SyntaxError: invalid syntax
All I want to do is place some png images in an array so I can then later pick them at random
Any help welcome.
Reply
#2
You're missing a closing parenthesis on the previous line.
Reply
#3
Thanks for that, should have spotted it, open 3, close 3
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020