For a regular expression, you would use:
re.match(r'Run.*.py$')
A quick explanation:
- . means match any character.
- * means match any repetition of the previous character (hence .* means any sequence of chars)
- is an escape to escape the explicit dot
- $ indicates "end of the string", so we don't match "Run_foo.py.txt"
However, for this task, you're probably better off using simple string methods. ie.
filename.startswith("Run") and filename.endswith(".py")
Note: if you want case insensitivity (ie. matching "run.PY" as well as "Run.py", use the re.I option to the regular expression, or convert to a specific case (eg filename.lower()) before using string methods.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…