Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

How to use glob.escape() function in python

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)

Source by www.alixaprodev.com #
 
PREVIOUS NEXT
Tagged: #How #function #python
ADD COMMENT
Topic
Name
2+9 =