mardi 13 octobre 2020

How to open an image from a directory using Python

So I have a folder with tons of pictures in it, and I want to write a program that randomly picks one of the pictures out of thousands and opens it.

Here's what I have so far:

import random, os

random_pic = random.choice(os.listdir("D:/de_clutter/memez/anmu")) 
open(random_pic)

all this does is give me the name of the picture, but I don't know how to open it.




Aucun commentaire:

Enregistrer un commentaire