python实时读取日志,三行代码简单粗暴

废话不多说直接上代码,命名xx.py

import sys
while True:
line = sys.stdin.readline()
print(line)

使用方式:tail -f xxxx.log | xx.py

可以把print()改写成你要处理的方法。简单快捷。

posted on 2019-06-06 18:57  WalkerWang731  阅读(960)  评论(0编辑  收藏  举报

导航