Best way to choose a random file from a directory

/ Published in: Python
Save to your folder(s)

Copy this code and paste it in your HTML
  1. import os, random
  2. random.choice(os.listdir("C:\\")) #change dir name to whatever


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.