详细如下:
#!/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)
运行结果就是查询到的结果
本文参考:
转载于:https://blog.51cto.com/weiruoyu/2347241