← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #203363]: Best way to open and close all files in a directory one at a time?

 

Question #203363 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/203363

    Status: Open => Answered

RaiMan proposed the following answer:
something like that:

import os
dir = "some directory"
for e in os.listdir(dir): # this starts the loop
    fileName = os.path.join(dir, e)
    print fileName
    f = open(e)
    # some operations on file f
    f.close()
print "all files read" # this prints after the loop ends.

again: faq 1437 should be helpful with loops

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.