函数一行一行读文件

def tail(path):
    #with open('fffs',encoding='utf-8') as f:
    f = open(path,encoding='utf-8')
    while True:
        line = f.readline()
        if line.strip():
            yield line.strip()



g = tail('fffs')
for i in g:
    print('sssss',i)
def tail(path):
    #with open('fffs',encoding='utf-8') as f:
    f = open(path,encoding='utf-8')
    while True:
        line = f.readline()
        if line.strip():
            yield line.strip()



g = tail('fffs')
for i in g:
    print('sssss',i)

 

posted on 2018-09-23 14:00  魔王李等猴哥的日子  阅读(96)  评论(0编辑  收藏  举报

导航