码迷,mamicode.com
首页 > 其他好文 > 详细

函数一行一行读文件

时间:2018-09-23 14:58:08      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:coding   open   path   strip()   div   读文件   函数   enc   tail   

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)

 

函数一行一行读文件

标签:coding   open   path   strip()   div   读文件   函数   enc   tail   

原文地址:https://www.cnblogs.com/limw/p/9692574.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!