Home > other >  Pygame write games
Pygame write games

Time:09-16

Is there anyone who know how to from a folder randomly selected images and export?

CodePudding user response:

The
refer to the original poster weixin_42368582 response:
is there anyone who knows how to images were randomly selected from a folder and export?

Random function, the random, generate a random number, then use the if statement choose according to random number to open the picture, is that ok?

CodePudding user response:

Now I thought of another way, write a function that put some pictures in the folder out randomly in a new folder, and then put the new folder pictures of all export, but for now to put pictures in the new folder, don't know how to export all pictures

CodePudding user response:

refer to the second floor weixin_42368582 response:
I now think of another way, write a function to put some pictures in the folder out randomly in a new folder, and then put the new folder pictures of all export, but for now to put pictures in the new folder, don't know how to export all pictures

Brother, can you read it one by one, the photo generated image object, after this object can be used directly with pictures,

CodePudding user response:

Has been solved, thank you

CodePudding user response:

Relatively simple method is:
1, use the OS module read the picture of the folder (OS) listdir (' fill path here))
2, the definition list like list=[]
3, using the for loop in + list. Append (pygame. Image. The load (' path ')) to import
4, using the random randint method to random images
  • Related