Hey there.
I’m using glob.glob function in order to get a list of all .txt files on a path that i provide.
The regex I’m feeding the function as C:\build\*.txt, but it works only for the root directory, and I’d like to find all text files in c:\build\, also c:\build\files\ha.txt for example.
How is it possible?
Thankss.
Notice that
glob.globwill accept unix shell wildcards and not regex objects (see the documentation).You might accomplish the feat of getting all
.txtfiles from all sub directories by usingos.walk. A method to give you such a list could be something like this: