I am trying to iterate through files using os.walk(), which works just fine using Python interpreter 2.7 or when debugging in pyCharm debug console, but when running the code, it returns just these 3 files on my C drive and does not scan subfolders.

['hiberfil.sys', 'pagefile.sys', 'swapfile.sys']

I am using the same code, which is

    for root, dirs, files in os.walk("C:\\"):
        print(files)

I have checked, pyCharm base interpreter is set to Python 2.7 which is supposed to be the same

0 Answers