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

3 answers 296 views
2 answers 229 views
1 answer 206 views
2 answers 296 views
1 answer 192 views
...