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 - 博客園

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章