The fnmatch
module matches filenames against a pattern, as Example 2-27 shows.
The pattern syntax is the same as that used in Unix shells. An
asterisk (*
) matches zero or more characters, and a
question mark (?
) matches exactly one character. You can
also use brackets to indicate character ranges, such as
[0-9]
for a single digit. All other characters
match themselves.
In Example 2-28, the translate
function converts a file pattern to
a regular expression.
The fnmatch
module is used by the glob
and find
modules.
18.119.162.49