f = open('a','r',encoding = 'gbk')#用r模式,gbk编码,打开文件a,
import sys,time#调用sys和time模块
count = 0#计数器
for i in f:#迭代器
sys .stdout.flush#边输出边刷新
time.sleep(1)#间隔1秒
if count == 4:#判断
break#跳出循环
print(i.strip()) # strip,取消每行之间的空行
count += 1#计时器
f.close
转载于:https://www.cnblogs.com/0312abcde/p/9657176.html