A simple demo that is close to what you want.
No path is given so you have the script
Will random pick 1 image,and show it it browser or OS image viewer.
#rand_pick.py import webbrowser import random import os def rand_numb(): numb = random.randrange(1, 6) return numb def pics(numb): for img in os.listdir(): if numb in img: webbrowser.open(img) if __name__ == '__main__': numb = str(rand_numb()) pics(numb)So in folder 5 images(pic_1.jpg, pic_2.jpg..ect).
No path is given so you have the script
rand_pick.py
in same folder as images.Will random pick 1 image,and show it it browser or OS image viewer.