fileinput.filelineno() in Python Last Updated : 22 Apr, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report With the help of fileinput.filelineno() method, we can get the line number for every line on line read for every file from input file by using fileinput.filelineno() method. Syntax : fileinput.filelineno() Return : Return the line number for every file. Example #1 : In this example we can see that by using fileinput.filelineno() method, we are able to get the line number for every line read for every file from the given files by using this method. Input File - Python3 1=1 # import fileinput import fileinput # Using fileinput.filelineno() method for line in fileinput.input(files ='gfg.txt'): print('{}. '.format(fileinput.filelineno()) + line) Output : Example #2 : Input File - Python3 1=1 # import fileinput import fileinput # Using fileinput.filelineno() method for line in fileinput.input(files =('gfg.txt', 'gfg1.txt')): print('{}. '.format(fileinput.filelineno()) + line) Output : Comment More infoAdvertise with us Next Article fileinput.input() in Python J jitender_1998 Follow Improve Article Tags : Python Python fileinput-library Practice Tags : python Similar Reads fileinput.filename() in Python With the help of fileinput.filename() method, we can get the last used file name which we have used so far by using fileinput.filename() method. Syntax : fileinput.filename() Return : Return the last used file name. Example #1 : In this example we can see that by using fileinput.filename() method, w 1 min read fileinput.lineno() in Python With the help of fileinput.lineno() method, we can get the line number for every line on line read from input file by using fileinput.lineno() method. Syntax : fileinput.lineno() Return : Return the line number. Example #1 : In this example we can see that by using fileinput.lineno() method, we are 1 min read fileinput.input() in Python With the help of fileinput.input() method, we can get the file as input and can be used to update and append the data in the file by using fileinput.input() method. Python fileinput.input() Syntax Syntax : fileinput.input(files) Parameter : fileinput module in Python has input() for reading from mul 2 min read fileinput.isfirstline() in Python With the help of fileinput.isfirstline() method, we can get the boolean value as True if line read from the file is very first line else false by using fileinput.isfirstline() method. Syntax : fileinput.isfirstline() Return : Return True if line read is first line of that file. Example #1 : In this 1 min read File Handling in Python File handling refers to the process of performing operations on a file such as creating, opening, reading, writing and closing it, through a programming interface. It involves managing the data flow between the program and the file system on the storage device, ensuring that data is handled safely a 7 min read Read a file line by line in Python Python provides built-in functions for creating, writing, and reading files. Two types of files can be handled in Python, normal text files and binary files (written in binary language, 0s, and 1s). In this article, we are going to study reading line by line from a file.Example:Pythonwith open('file 4 min read Like