write a python program to read last n lines of a file

Solutions on MaxInterview for write a python program to read last n lines of a file by the best coders in the world

showing results for - "write a python program to read last n lines of a file"
Alycia
27 Jun 2018
1def read_lastnlines(fname,n):
2	with open('file1.txt') as f:
3		for line in (f.readlines() [-n:]):
4			print(line)
5
6read_lastnlines('file1.txt',3)
queries leading to this page
open last lines file python7 write a python program to read last n lines of a fileprinting the last n lines in a fileread last line of file pythonwrite a python program to read last n lines of a filehow to read the last line of a text file in pythonpython read last 10 lines of filepython last line of filepython read last line from text filepython read last n lines of filepython program to read the last n lines from a file and copy it to another file python script to dowload a file and write only last 20 linesread last lines of a text file pythonprogram to print last n lines of a file in pythonpython print last n lines of fileread only last line of file pythonpython read the last n lines of a fileprint n last lines from file pythonprint 10 from last lines of file pythonread last n lines of a file in pythonhow to read last 10 lines of a file in pythonread last line in a text file with pythonpython for last line in filecan i take just the last line in a file pythonhow do i read the last 10 lines of a file in python 3fpython get the last 10 lines of a file without readingpython read first and last line in filepython program to read last n lines of a filelast line in file pythonview last n lines of file pythonwrite a python program to read first n and last n lines of a fileread last n lines of file pythonhow to read last n lines of a file in pythonpython open file read last n lineshow to print last 10 lines of a file in pythonpython read file last linewrite on last line of a file pythonread last 10 lines of file pythonwrite a python program to read the last n lines of a fileefficiently read first and last lines of a file pythonwrite a python program to read last n lines of a file 15 write a python program to read last n lines of a file how to read the last10 lines of a file in pythonpython write data to file only last 10 linesread last lines of text file pythonwrite a python program to read last n lines of a file