File Handling (read, write, append, context manager, pathlib) - Python Tutorial for Beginners #15
6views
0010:05
T
Taught by Celeste AI - AI Coding Coach
View on YouTubeDescription
Learn Python file handling in this beginner-friendly tutorial! 📂
In this lesson, you will learn:
✅ Opening files with open() function
✅ File modes: read (r), write (w), append (a)
✅ Reading files with read(), readlines(), for loop
✅ Writing and appending to files
✅ Context managers with the with statement
✅ Processing file data into dictionaries
✅ Working with pathlib for modern file operations
✅ Mini Project: Log Manager
🕐 Timestamps:
0:00 - Introduction
0:22 - File Basics Explained
0:46 - File Basics Demo
3:08 - File Operations Explained
3:32 - File Operations Demo
6:24 - Log Manager Explained
6:48 - Log Manager Demo
9:42 - Recap
10:17 - End
💻 Source Code: https://github.com/GoCelesteAI/python_file_handling
📚 Code from this lesson:
# Write to a file
with open("hello.txt", "w") as f:
f.write("Hello, World!\n")
# Read entire file
with open("hello.txt", "r") as f:
content = f.read()
# Read lines as list
with open("hello.txt", "r") as f:
lines = f.readlines()
# Append to file
with open("hello.txt", "a") as f:
f.write("New line!\n")
# Pathlib
from pathlib import Path
content = Path("data.txt").read_text()
🔗 Previous: Lesson 14 - List Comprehensions
🔗 Next: Lesson 16 - Exception Handling
#Python #PythonTutorial #LearnPython #Programming #FileHandling #ReadWrite #Pathlib #PythonBasics
Tags
Python, Python tutorial, Python for beginners, learn Python, file handling, open file, read file, write file, append file, with statement,
context manager, pathlib, readlines, CelesteAI
Tags
PythonPython tutorialPython for beginnerslearn Pythonfile handlingopen fileread filewrite fileappend filewith statementcontext managerpathlibreadlinesCelesteAI
Back to tutorialsOpen in YouTube
Duration
10:05
Published
February 8, 2026
Added to Codegiz
March 15, 2026