“glob python” Réponses codées

globe python

import glob

print 'Named explicitly:'
for name in glob.glob('dir/subdir/*'):
    print '\t', name

print 'Named with wildcard:'
for name in glob.glob('dir/*/*'):
    print '\t', name
Clumsy Cassowary

Comment utiliser le module Python Glob


import glob
# path of the current directory
path = '.'
curfiles = glob.glob(path + '/*.html')
for file in curfiles:
    print(file)
    

sous-répertoires de Python Glob

import glob

subdirectories = glob.glob("./*/")
Attractive Addax

glob python

# Python program to find files
# recursively using Python
  
  
import glob
  
  
# Returns a list of names in list files.
print("Using glob.glob()")
files = glob.glob('/home/geeks/Desktop/gfg/**/*.txt', 
                   recursive = True)
for file in files:
    print(file)
  
  
# It returns an iterator which will 
# be printed simultaneously.
print("\nUsing glob.iglob()")
for filename in glob.iglob('/home/geeks/Desktop/gfg/**/*.txt',
                           recursive = True):
    print(filename)
Cdev2

Réponses similaires à “glob python”

Questions similaires à “glob python”

Plus de réponses similaires à “glob python” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code