# -*- coding: utf-8 -*-
import sys
import time
def printlines(lines,line_start=0):
if len(lines)>10:
line_start= len(lines)-10
while line_start<len(lines):
print lines[line_start]
line_start=line_start+1
else:
while line_start<10:
print lines[line_start]
line_start=line_start+1
def get_last_lines(filepath,f='',n=10):
import os
already_print_num=0
if not os.path.exists(filepath):
print 'no such file'
sys.exit()
return
readfile = open(filepath,'r')
lines = readfile.readlines()
if f=='':
printlines(lines)
else: #不会在复制了输入文件的最后的指定单元后终止
while True: #每隔一秒刷新一次
if already_print_num<len(lines):
printlines(lines)
else:
readfile = open(filepath,'r')
lines = readfile.readlines()
while already_print_num<len(lines):
print lines[already_print_num]
already_print_num=already_print_num+1
already_print_num=len(lines)
time.sleep(1)
readfile.close()
import sys
import time
def printlines(lines,line_start=0):
if len(lines)>10:
line_start= len(lines)-10
while line_start<len(lines):
print lines[line_start]
line_start=line_start+1
else:
while line_start<10:
print lines[line_start]
line_start=line_start+1
def get_last_lines(filepath,f='',n=10):
import os
already_print_num=0
if not os.path.exists(filepath):
print 'no such file'
sys.exit()
return
readfile = open(filepath,'r')
lines = readfile.readlines()
if f=='':
printlines(lines)
else: #不会在复制了输入文件的最后的指定单元后终止
while True: #每隔一秒刷新一次
if already_print_num<len(lines):
printlines(lines)
else:
readfile = open(filepath,'r')
lines = readfile.readlines()
while already_print_num<len(lines):
print lines[already_print_num]
already_print_num=already_print_num+1
already_print_num=len(lines)
time.sleep(1)
readfile.close()