“Python Glob.Glob Recursive” Kod odpowiedzi

Python Glob.Glob Recursive

configfiles = glob.glob('C:/Users/sam/Desktop/file1/**/*.txt', recursive=True)
DreamCoder

Python Glob.Glob Recursive

import os

path = 'C:/Users/sam/Desktop/file1'

configfiles = [os.path.join(dirpath, f)
    for dirpath, dirnames, files in os.walk(path)
    for f in files if f.endswith('.txt')]
DreamCoder

Python Glob.Glob Recursive

import os
import fnmatch

path = 'C:/Users/sam/Desktop/file1'

configfiles = [os.path.join(dirpath, f)
    for dirpath, dirnames, files in os.walk(path)
    for f in fnmatch.filter(files, '*.txt')]
DreamCoder

Odpowiedzi podobne do “Python Glob.Glob Recursive”

Pytania podobne do “Python Glob.Glob Recursive”

Więcej pokrewnych odpowiedzi na “Python Glob.Glob Recursive” w Python

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu