python获取并判断当前目录下含有某字符的文件名


if
    p = subprocess.Popen("python C:\Windows" + file_name, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    (stdout, stderr) = p.communicate()

请教一下:
我需要用python判断当前目录下是否含有x_x的文件,例(Graph_cellX_X.csv),此cellx_x中的x为不固定数字,1_2,1_3之类的或2_2,2_3之类的,此时获取文件名并判断的语句是什么?或者说另一种,先获取文件名进行变量存储,再用存储的变量进行判断的语句应该怎样写呢?

直接在os.lisdir()返回的列表遍历
然后if 判断的时候用正则匹配来判断是否匹配到需要的字符串
re.findall(r'(\d_\d)',filename)
if re.findall(r'(\d_\d)',filename):

import os
doc_path=""#你的文件夹路径
for f in os.listdir(doc_path):
    print(f)
    #这个你就要根据你的需求自行判断了
    if :
        pass