Answers for "pythons os module choose random file"

0

pythons os module choose random file

import os
import random
import dircache

dir = 'some/directory'
filename = random.choice(dircache.listdir(dir))
path = os.path.join(dir, filename)
Posted by: Guest on June-13-2021

Browse Popular Code Answers by Language