Veeeeery Basic Question
effbot at telia.com
Mon Feb 28 00:19:29 CET 2000
Eric Stewart <ericstewart at mindspring.com> wrote:
> I guess this will be a CGI script that will run in the Directory
> cgi-bin, which will be referenced by the HTML.
sure. but if this is really your first script,
you better play with it a while before you
try to run it under the web server...
> The image files which i will select from will be in a seperate
> directory, i.e C:Web Stuff\Images
> Here is the problem I'm having. (Understand that I've NEVER written
> anything before). How do I iterate over the image files in the
> directory? I thought that a for loop would work. sort of...
> import random
> for myFiles in someDirectory:
> return myImage
here's a start:
# get a list of files
myFiles = os.listdir("c:/Web Stuff/Images")
# pick a random file from that list
hope this helps (a little bit, at least)
More information about the Python-list