Os.walk is not coming

While trying to automate some process, I came across this apparently very strange behavior of Python os.walk(): when I give it some directory, it just does nothing. However, when I pass in the parent directory, it is correctly overwritten in a path that does not seem to work when transferring directly.

For instance:

for root, _, _ in os.walk('F:\music'):
    print(root)

outputs the following result:

F: \ music
[...]
F: \ music \ test
F: \ music \ test \ broken
F: \ music \ test \ broken \ Boards_Of_Canada
F: \ music \ test \ broken \ Brian_Eno
[...]

But when I try using F: \ music \ test (which was recursed in the order when it os.walk()was called in its parent) as such:

for root, _, _ in os.walk('F:\music\test'):
    print(root)

I don’t get anything at all.

- , ? - ? - os.walk()? .

+3
3

:

 for root, _, _ in os.walk('F:\music\test'):
     print(root)

... Python , , \t Tab. 'f:\\music\\test' r'F:\music\test' ( , .)

+18

, , . , , \t , slash-tee.

+7

os.path.normpath ( ), , -

for root, _, _ in os.walk (os.path.normpath ('F: / music / test')):

+2
source

All Articles