How to use to find files recursively?

I would like to list all files recursively in a directory. I currently have a directory structure like this:

I've tried to do the following:

from glob import glob

glob(os.path.join('src','*.c'))

But this will only get be files directly in the src subfolder, e.g. I get main.c but I will not get file1.c, file2.c etc.

from glob import glob

glob(os.path.join('src','*.c'))
glob(os.path.join('src','*','*.c'))
glob(os.path.join('src','*','*','*.c'))
glob(os.path.join('src','*','*','*','*.c'))

But this is obviously limited and clunky, how can I do this properly?

← Назад к списку