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

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

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

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

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

猜你喜欢

转载自www.cnblogs.com/walkerwang731/p/10986576.html