python读取文件后切片

 

from itertools import islice
with open(“1.txt") as f:
    for a in islice(f,0,2):
        print(a)

 

posted on 2018-12-07 16:57  一杯明月  阅读(2120)  评论(0编辑  收藏  举报