0

I have been at this for a few hours... how to use python to get all enclosing files from a folder... now by enclosing I mean all the files enclosed within a folder within a folder etc. So all the files beyond a certain point using Python.

I have tried to use glob.glob() and listdir() to do this, but those will just only work within the first level of code. I could get this to work if there was a way that python could differentiate between a file and a folder? Any suggestions?

4

1 に答える 1

5

You want os.walk(). It will give you a list of files and folders in each directory under the starting directory.

于 2012-07-14T00:35:20.827 に答える