0
import os, random
import numpy
from PIL import Image

path = "C:/Users/mark03/Desktop/rmv_1_loan_0908/images"
save_path = "C:/Users/mark03/Desktop/rmv_1_loan_0908/random"

file_list = os.listdir(path)
def selectRandom(file_list):
    return numpy.random.choice(file_list, 3, False)

print(selectRandom(file_list))

Hi there! I want to save 'my random choiced images' in my folder. But in this code,

I just check image names, but these images are not saved in my folder. So I want to plus code about save in my folder.

Is there any good way to solve the problem??? thank you!

enter image description here

Epsi95
  • 8,832
  • 1
  • 16
  • 34
황인성
  • 1
  • 1
  • 1
    [Why not upload images of code/errors when asking a question?](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question) – Selcuk Sep 09 '21 at 05:14
  • you need to iterate over the random file list using `for ... in` and save them to destination, check this one https://stackoverflow.com/questions/123198/how-do-i-copy-a-file-in-python – Epsi95 Sep 09 '21 at 05:21

0 Answers0