Veeeeery Basic Question
Fredrik Lundh
effbot at telia.com
Sun Feb 27 18:19:29 EST 2000
More information about the Python-list mailing list
Sun Feb 27 18:19:29 EST 2000
- Previous message (by thread): Veeeeery Basic Question
- Next message (by thread): Killin' Newbie question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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: > myImage=random.choice(Myfiles) > return myImage here's a start: ... import os import random # get a list of files myFiles = os.listdir("c:/Web Stuff/Images") # pick a random file from that list print random.choice(myFiles) ... hope this helps (a little bit, at least) </F>
- Previous message (by thread): Veeeeery Basic Question
- Next message (by thread): Killin' Newbie question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list