Answer the question
In order to leave comments, you need to log in
Why doesn't os.path.isdir work?
import os
import glob
def finder(path,mask):
os.chdir(path)
print(os.getcwd())
if len(glob.glob(mask)):
print(glob.glob(mask))
dir_list = os.listdir()
for dirt in dir_list:
if os.path.isdir(os.path.abspath(dirt)):# строка 1
print(dirt)
finder(dirt,mask)
else:
print(dirt,'is not dir')
Answer the question
In order to leave comments, you need to log in
Python - how to find files and skip directories in...
basepath = '/path/to/directory'
for fname in os.listdir(basepath):
path = os.path.join(basepath, fname)
if os.path.isdir(path):
# skip directories
continue
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question