python模糊查找匹配 文件 文件名 并列出来

详细如下:

#!/usr/bin/python
# -*- coding: utf-8 -*-

import os

pathlog = "/usr/local/nginx/log"
files = os.listdir(pathlog)
for f in files:
    if 'stat' in f and f.endswith('.log'):
        print ("Found it! " + f)

运行结果就是查询到的结果

本文参考:

如何用 Python 模糊搜索文件 - Lamfai - 博客园

转载于:https://blog.51cto.com/weiruoyu/2347241

你可能感兴趣的:(python模糊查找匹配 文件 文件名 并列出来)