第一步:创建一个文件
import time
def read_book(path,line=3,auto=False):
with open(path, mode='r') as f:
f.seek(0,2)
end_position=f.tell()
f.seek(0,0)
while True:
if auto== True:
# ...自动翻页。
for i in range(line):
print(f.readline(),end='')
time.sleep(1)
now_position=f.tell()
if now_position ==end_position:
break
else:
'''手动翻页'''
num=input('请输入N页码')
if num=='N':
for i in range(line):
print(f.readline(),end='')
now_position=f.tell()
if now_position==end_position:
print()
print('再接再厉 ')
break
else:
print('你好!,输错了请重新输入。。。')
read_book('file/e.txt', auto=True) #把文件穿入