最近在学习python老师布置了一个作业写一个文件阅读器:
要求如下:
可上下翻页
有自动翻页阅读和手动控制
实战:
代码如下:
time tl = [] readers(path,lines=,auto=,times=): (path,) f: f.seek(,) last = f.tell() f.seek() i (lines): (f.readline()) tl.append(f.tell()) auto == : f.tell() < last: i (lines): (f.readline()) time.sleep(times) : f.tell() < last: contorl = () contorl == contorl == : () contorl == contorl ==: i (lines): (f.readline()), tl.append(f.tell()) contorl == contorl ==: (tl) == : () (tl) == : f.seek() i (lines): (f.readline()), tl.pop() : f.seek(tl[-]) i (lines): (f.readline()), tl.pop() () __name__ == : readers()
时间: 2024-10-15 06:17:00