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 261 views
3 answers 299 views
2 answers 230 views
1 answer 207 views
2 answers 296 views
1 answer 193 views
...