标签:stderr files lin int 读取 os.path size print line
import time
import os
import sys
if len(sys.argv)!=2:
print >> sys.stderr ,"Please specify filename to read"
filename = sys.argv[1]
if not os.path.isfile(filename):
print >> sys.stderr ,"Given file: \"%s\" is not a file" % filename
with open(filename,‘r‘) as f:
filesize = os.stat(filename)[6]
f.seek(filesize)
while True:
where = f.tell()
line = f.readline()
if not line:
time.sleep(where)
else:
print line
标签:stderr files lin int 读取 os.path size print line
原文地址:http://www.cnblogs.com/boooobao/p/6476835.html