“Python Glob” Kode Jawaban

Python Glob

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

Subdirektori 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

Jawaban yang mirip dengan “Python Glob”

Pertanyaan yang mirip dengan “Python Glob”

Lebih banyak jawaban terkait untuk “Python Glob” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya