“Glob Python” 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

Cara menggunakan modul python glob


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

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 “Glob Python”

Pertanyaan yang mirip dengan “Glob Python”

Lebih banyak jawaban terkait untuk “Glob Python” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya