Posted By

magicrebirth on 02/18/11


Tagged

file dir python random os


Versions (?)

Best way to choose a random file from a directory


 / Published in: Python
 

URL: http://stackoverflow.com/questions/701402/best-way-to-choose-a-random-file-from-a-directory

  1. import os, random
  2. random.choice(os.listdir("C:\\")) #change dir name to whatever

Report this snippet  

You need to login to post a comment.