Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

select random img in python using os.listdir

import random, os
path = r"C:UsersGDesktopscientific-programming-2014-masterscientific-programming-2014-masterhomeworkassignment_3cifar-10-pythoncifar-10-batches-py"
random_filename = random.choice([
    x for x in os.listdir(path)
    if os.path.isfile(os.path.join(path, x))
])
print(random_filename)
Comment

PREVIOUS NEXT
Code Example
Python :: get webpage python 
Python :: stack in python using linked list 
Python :: python sys 
Python :: python combinations 
Python :: fizz buzz 
Python :: groupby and list 
Python :: python print fraction 
Python :: python list add to start 
Python :: what are test cases in python 
Python :: index duplicates python 
Python :: how to give float till 5 decimal places 
Python :: first and last name generator python 
Python :: Python - How To Check Operating System 
Python :: pandas split tuple column 
Python :: find index of element in array python 
Python :: dataframe python 
Python :: check space in string python 
Python :: python queue not empty 
Python :: tuple count in python 
Python :: import matplotlib pyplot as plt 
Python :: python get attribute value with name 
Python :: python find if string contains space 
Python :: find string in list and return index python 
Python :: pyqt5 drop down menu 
Python :: create empty numpy array 
Python :: type conversion python 
Python :: binary search recursive python 
Python :: python import 
Python :: python type annotations list of possible values 
Python :: python catch any exception 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =