Course
BasicWorking with Files and Directories in Python
Would you like to learn how to work with files and directories in Python? Check out this interactive course!
Lifetime access
limited to this course only
$29
Unlimited lifetime access
to all 13 present and future courses
$ 99
$ 349
72% OFF
Do you deal with files and directories daily? Do you want to load data into the program more efficiently, store the results, and easily share them with others? We have something for you! Take this interactive course to learn how to work with files and directories in Python.
We have created this Python course primarily for people who are just starting their adventure with programming. However, this does not mean that more advanced users will not find something for themselves. This is a complete course on how to work with files and directories in Python.
In the first section, youâll learn the basics of working with files: how to open and close files and the modes for working with files in Python. In particular, youâll learn how to use the with syntax, the most convenient way to work with files in Python.
Youâll also learn different ways to read files into Python: with read(), with readline() or readlines(), and with a for loop. In addition, youâll learn how to handle exceptions when working with files.
In the next sections, youâll learn how to work with directories and how to manage files in Python. Soon youâll create directories, remove and rename files and directories, and list the contents of a directory with ease.
Youâll also learn to find file attributes such as the date of modification or the date of access. In addition, youâll learn how to work with file paths and file names.
In the last section, youâll discover the power of the pathlib module. The modern pathlib module offers an easier and more intuitive way to work with files and directories in Python. Finally, a quiz will help you consolidate and verify your newly acquired knowledge.
In this interactive course, youâll write real Python programs to solve the exercises. Our web-based platform will run your commands and verify your solutions. You donât need to install anything on your computer.
To take this course, itâs best to have learned the basics of Python syntax from our Python Basics series (Python Basics. Part 1, Python Basics. Part 2, and Python Basics. Part 3) or have the equivalent knowledge. You should already know about variables, if statements, for and while loops, and how to create functions in Python.
You might already have some basic knowledge of how to work with files, but itâs not a requirement. Weâll review all you need to know on the topic in the course.
What's in It for Me?
- 104 interactive exercises to practice your programming skills: solve them at your own pace, from anywhere and at any time, interacting with hands-on exercises for improved retention
- Lifetime access to the course: when you purchase the course, you'll get instant personal access to all of its content
- Certificate of completion: after you successfully finish all of the exercises, you'll get a downloadable PDF certificate to showcase your accomplishment
- 30-day, money-back guarantee: if you're not satisfied with the quality of the course, you can get a refund within 30 days of your purchase
- Hints for the exercises: you can ask questions and share insights with other members of the community through the Discuss tab (we'll be more than happy to answer! ð)
What Are the Requirements?
- A web browser
- Knowledge of basic Python syntax, for example, from our Python Basics series (Python Basics. Part 1, Python Basics. Part 2, and Python Basics. Part 3)
What Will I Learn in This Course?
- Youâll learn about the functions open() and close(), which allow you to open and close files in Python.
- Youâll learn about different modes for working with files in Python: reading (r mode), writing (w mode), appending (a mode), and others.
- Youâll practice the with syntax, the most common and convenient syntax for working with files in Python.
- Youâll learn how to handle exceptions that arise when working with files in Python.
- Youâll learn about various functions for reading data from files in Python: read(), readline(), readlines(), and looping over text files with a for loop.
- Youâll learn about various functions for writing data to a file in Python: write() and writelines().
- Youâll learn how to work with directories in Python: how to create directories, how to remove or rename directories, and how to list the contents of a directory.
- Youâll learn how to manage files in Python: how to move or rename files and how to find out the modification date or file permissions.
- In addition to the traditional Python file API in os and os.path modules, youâll learn the modern Python file API in the pathlib module.
Who Should Take This Course?
- Students taking programming classes who want to review and practice their skills related to working with files in Python
- Data Analysts who need to work with various files in Python
- Aspiring Python programmers who want to learn or review their knowledge in working with files in Python
- Hobbyists looking for exercises on how to work with files in Python
Table of contents
Course progress
Exercises completed
1.
Introduction
Learn basic information about paths, files, and directories
2.
Working with Files
Learn how to perform common file operations like write, read, and delete.
3.
Working with Directories
Learn how to create, rename, and move directories in Python. Get to know how to list the content of a directory.
4.
File Management in Python
Learn how to perform common file operations like rename, move, and delete.
5.
Using the pathlib Module
Learn another way to manage files and directories with pathlib.
