0

I'm trying to scan all directories inside a folder that has two special characters in it. The code is below.

import os
__loc__ = os.path.realpath(os.path.join(os.getcwd(),os.path.dirname(__file__))
path = os.path.join(__loc__,'Ração')
for root,dirs,files in os.walk(path):
   for dir in dirs:
     print(dir)

But nothing appears...

Does anybody know an easy solution to accept special characters in

os.walk argument?


Edit: I don't get an error from the code. It just do not iterate.

pbriquet
  • 1
  • 1
  • 1
    Did you print the `path` to make sure it was what it should be? `getcwd()` often returns unexpected results. – Mark Ransom Oct 06 '22 at 00:01
  • Yes, I printed. It is ok, it works without special characters like "ç" – pbriquet Oct 06 '22 at 15:45
  • Well when I tried it with the exact directory name that you used in the question, it worked for me. You'll need to try harder to make a reproducible sample. – Mark Ransom Oct 06 '22 at 16:03

0 Answers0