I'm trying to write a program that picks a random photo, and i built this code:
random_image_path = random.choice([x for x in os.listdir(path) if os.path.isfile(os.path.join(path, x))])
print(random_image_path)
but after I started the program it sometimes prints ".ini" files... what should I do if I want only .png or .jpeg files? thanks!
Aucun commentaire:
Enregistrer un commentaire