#38 | Python Beginners Tutorial in Tamil | File Handling | Iterating Over Lines in File in Python

preview_player
Показать описание
#38 | Python Beginners Tutorial in Tamil | File Handling | Iterating Over Lines in File in Python

We will now use this file as input in a program that will do some data processing. In the program, we will examine each line of the file and print it with some additional text. Because readlines() returns a list of lines of text, we can use the for loop to iterate through each line of the file.
A line of a file is defined to be a sequence of characters up to and including a special character called the newline character. If you evaluate a string that contains a newline character you will see the character represented as \n. If you print a string that contains a newline you will not see the \n, you will just see its effects (a carriage return). When you are typing a Python program and you press the enter or return key on your keyboard, the editor inserts a newline character into your text at that point.

To make the code a little simpler, and to allow for more efficient processing, Python provides a built-in way to iterate through the contents of a file one line at a time, without first reading them all into a list. I have found that this is confusing to students initially, so I don’t recommend doing it this way, until you get a little more comfortable with python. But this idiom is preferred by Python programmers, so you should be prepared to read it. And when you start dealing with big files, you may notice the efficiency gains of using it.

__
like our face book page..
--------------------------------------------------------------------------------
send request our channel official facebookprofile...
---------------------------------------------------------------------------------

#santratechspot
Рекомендации по теме
Комментарии
Автор

Super bro. Your explanation very nice and clear👍

paulpandi
Автор

Namba anga \n mudikava illaya aprm Eppadi line leave panni print panna mudiyum

vaishnavivaishu
Автор

Bro all built in fuction video podunga

jdaniel_viragnoor
visit shbcf.ru