Regular expression to match start of filename and filename extension

后端 未结 8 889
离开以前
离开以前 2020-12-08 15:35

What is the regular expression to match strings (in this case, file names) that start with \'Run\' and have a filename extension of \'.py\'?

The regular expression s

8条回答
  •  孤街浪徒
    2020-12-08 16:16

    You don't need a regular expression, you can use glob, which takes wildcards e.g. Run*.py

    For example, to get those files in your current directory...

    import os, glob
    files = glob.glob( "".join([ os.getcwd(), "\\Run*.py"]) )
    

提交回复
热议问题