可以使用Python中的os模块和字符串操作进行解决,代码示例如下:
import os
file_list = [] for file in os.listdir("path/to/folder"): if os.path.isfile(file): file_list.append(file)
substring = "example"
for file in file_list: if substring in file.split(".")[0]: print("Found file with matching prefix:", file)