How to read a specific line from text file in Python

1 Answer

0 votes
line_number = 4
with open('info.txt', 'r') as f:
    for i in range(line_number - 1):
        next(f)
    print(next(f))


'''
run:

python design philosophy emphasizes code readability 

'''

 



answered Jun 22, 2020 by avibootz

Related questions

1 answer 265 views
3 answers 305 views
2 answers 236 views
1 answer 213 views
2 answers 301 views
1 answer 195 views
...