I am having some difficulty writing a function that will search through a directory for a file that matches a specific regular expression (which I have compiled using ‘re.compile’). So my question is: How do I search through a directory (I plan to use os.walk) for a file that matches a specific regular expression? An example would be very much appreciated. Thanks in advance.
I am having some difficulty writing a function that will search through a directory
Share
This will find all files starting with two digits and ending in gif, you can add the files into a global list, if you wish: