1def read_lines(fname,n,mode='r+'):
2 with open(fname) as f:
3 for i in range(n):
4 print(f.readline())
5
6read_lines('file1.txt',2)
7#######################
8def readnline(fname,lines,mode='r+'):
9 with open(fname) as f:
10 li = [ next(f) for i in range(lines)]
11 print(li)
12
13readnline('file1.txt',1)
14
15#############################