File Operations in Python
Reading and writing data files.
1
File Operations in Python
Python makes it easy to work with files for reading and writing data. In this lesson, we’ll explore how to handle files in Python, including opening, reading, writing, and closing them.

2
Opening Files
To work with a file in Python, you first need to open it using the open() function. The open() function requires the file name and the mode (e.g., 'r' for reading, 'w' for writing).
Example:
file = open('example.txt', 'r')