linecache.getline() in Python Last Updated : 22 Apr, 2020 Improve Improve Like Article Like Save Share Report With the help of linecache.getline() method, we can get a particular line by providing a line number, one of the usecase for this method is to find the syntax error in the given line number within a big file by using linecache.getline() method. Syntax : linecache.getline(filename, lineno) Return : Return the content of given line number. Input File : Example #1 : In this example we can see that by using linecache.getline() method, we are able to get the content of a given line from a big file by using this method. # import linecache import linecache as lc # Using linecache.getline() method gfg = lc.getline('File.txt', 1) print(gfg) Output : Example #2 : # import linecache import linecache as lc # Using linecache.getline() method gfg = lc.getline('File.txt', 2) print(gfg) Output : Like Article Suggest improvement Previous Single Page Portfolio Using Flask Next PyQt5 - Name of Progress Bar Share your thoughts in the comments Add Your Comment Please Login to comment... Similar Reads Important differences between Python 2.x and Python 3.x with examples Python program to build flashcard using class in Python Python | Merge Python key values to list Reading Python File-Like Objects from C | Python Python | Add Logging to a Python Script Python | Add Logging to Python Libraries JavaScript vs Python : Can Python Overtop JavaScript by 2020? Python | Visualizing O(n) using Python Python | Index of Non-Zero elements in Python list Python | Convert list to Python array Like J Jitender_1998 Follow Article Tags : Python-linecache Python Practice Tags : python