Python Series | Part 34 | File Handling Part3 | With Statement,Read,ReadLine and ReadLines Methods

Опубликовано: 24 Февраль 2024
на канале: ARIVU INFO
22
1

The with statement is useful in the case of manipulating the files. 
Syntax :
with open(file name, access mode) as file-pointer:   
It is always suggestible to use the with statement in the case of files because, if the break, return, or exception occurs in the nested block of code then it automatically closes the file, we don't need to write the close() function. It doesn't let the file to corrupt.

The syntax of the read() method:

fileObject.read(count)  
Here, the count is the number of bytes to be read from the beginning of the file. If the count is not specified, then it may read the content of the file until the end.

The readline() method reads the lines of the file from the beginning, i.e., if we use the readline() method two times, then we can get the first two lines of the file.

Python provides also the readlines() method which is used for the reading lines. It returns the list of the lines till the end of file(EOF) is reached.
If this video is useful to you, please like and share If you didn't subscribe kindly subscribe. So that you will get a notification about my new videos

Python Course full playlist:    • Python Tutorial in Tamil  
C Language Course full playlist:    • C Language Full Course  
Python Course English full playlist:    • Python Tutorial in English  
Java Course English full playlist:    • Java Tutorial in English  


Subscribe to our channel by clicking here 👉👉🏾    / @arivuinfo_6666  
#ARIVU_INFO


На этой странице сайта вы можете посмотреть видео онлайн Python Series | Part 34 | File Handling Part3 | With Statement,Read,ReadLine and ReadLines Methods длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь ARIVU INFO 24 Февраль 2024, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 22 раз и оно понравилось 1 зрителям. Приятного просмотра!