Tutorial -21 Python File Handling Open Read .txt file Part-1

Опубликовано: 06 Ноябрь 2024
на канале: Priyanka Jamdar
58
1

File handling is an important part of any web application.

Python has several functions for creating, reading, updating, and deleteing files.

File Handling
The key function for working with files in Python is the open() function.

The open() function takes two parameters; filename, and mode.

There are four different methods (modes) for opening a file:

"r" - Read - Default value. Opens a file for reading, error if the file does not exist

"a" - Append - Opens a file for appending, creates the file if it does not exist

"w" - Write - Opens a file for writing, creates the file if it does not exist

"x" - Create - Creates the specified file, returns an error if the file exists