Select randomly x files in subdirectories
问题 I need to take exactly 10 files (images) in a dataset randomly, but this dataset is hierarchically structured. So I need that for each subdirectory that contains images hold just 10 of them randomly. Is there an easy way to do that or I should do it manually? def getListOfFiles(dirName): ### create a list of file and sub directories ### names in the given directory listOfFile = os.listdir(dirName) allFiles = list() ### Iterate over all the entries for entry in listOfFile: ### Create full path