标签:python
with open(‘log.txt‘,‘rb‘) as fd:
for i in fd:
offs=-5
while True:
fd.seek(offs,2)
data=fd.readlines()
if len(data) > 1:
print(‘文件的最后一行是%s‘ %(data[-1].decode(‘utf-8‘)))
break
offs*=2
本文出自 “学习交流” 博客,请务必保留此出处http://725689.blog.51cto.com/715689/1973394
标签:python
原文地址:http://725689.blog.51cto.com/715689/1973394