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 370 views
3 answers 453 views
2 answers 362 views
1 answer 323 views
2 answers 416 views
1 answer 284 views
...