Python os.walk() loop directories for attribute
Question: I have a text file containing directory names on each line (1, 2, 3), how can
I iterate through the text file and have the result inserted into os.walk?

So far, I have

    
    
    import os
    from os import listdir
    
    dir_file = open("list.txt", "r")
    
    for root, dirs, files in os.walk(dir_file):
        for name in files:
            print(os.path.join(root, name))
        for name in dirs:
            print(os.path.join(root, name))
    

I have used a combination of while loops and for loops and if statements to
try and perform this, but I've had no luck.

Any help?

Thanks


Answer: How about:

    
    
    rdf = []
    for fff in dir_file:
       for r, d, f in os.walk(fff):
          rdf.append(r, d, f)
    

