Nov-22-2020, 07:15 AM
Hi,
I'm trying to use 'os.walk' to find all the subdirectories and files in the root dir.
In the first "for" loop, the code generates an error if I use:
Here is the code.
Thank you.
I'm trying to use 'os.walk' to find all the subdirectories and files in the root dir.
In the first "for" loop, the code generates an error if I use:
os.path.join(root, dirs)to get rid of an error I'm using a workaround :
root+'\\'+drI understand 'workaround' is not a good thing to use.
Here is the code.
import os p = 'c:\\02' for root, dirs, files in os.walk(p): for dr in dirs : #r = os.path.join(root, dirs) #print ("Dir/Path -- ", r) dp = root+'\\'+dr print (dp) for file in files: rf = os.path.join(root, file) print ('Roor+file-->> ',rf)Any help is appriciated!
Thank you.