Home > database >  How to extract elements of a list into a folder in Python
How to extract elements of a list into a folder in Python

Time:03-24

I have a list of image objects. I want to build a folder comprising the images of this list, so that I can download the folder. Is there a way to do this?

CodePudding user response:

The PIL Image object has a save function that you can make use of.

Simply loop over each Image object and call the save function and provide it with the path of the image.

Example:

for i, img in enumerate(list_of_imgs):
    img.save(f"{dir}/{i}.jpg")
  • Related