废话不多说直接上代码,命名xx.py
import syswhile True: line = sys.stdin.readline() print(line)
使用方式:tail -f xxxx.log | xx.py
可以把print()改写成你要处理的方法。简单快捷。
python实时读取日志,三行代码简单粗暴
原文:https://www.cnblogs.com/walkerwang731/p/10986576.html