Answers for "glob.escape() method in Python Glob Module"

0

glob.escape() method in Python Glob Module

import glob

files = glob.glob("D:\\**\\*.jpg",recursive=True)
# All jpg files
print(files)

#JPEGs files with special characters in their name
# set of special characters _, $, #
char_seq = "_$#"
for char in char_seq:
    results = "*" + glob.escape(char) + "*" + ".jpg"
    for file in (glob.glob(results)):
        print(file)
Posted by: Guest on August-08-2021

Code answers related to "glob.escape() method in Python Glob Module"

Python Answers by Framework

Browse Popular Code Answers by Language