Would you like to learn how to work with files and directories in Python? Check out this interactive course!
limited to this course only
Unlimited lifetime access
to all 13 present and future courses
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.
Learn basic information about paths, files, and directories
Learn how to perform common file operations like write, read, and delete.
Learn how to create, rename, and move directories in Python. Get to know how to list the content of a directory.
Learn how to perform common file operations like rename, move, and delete.
Learn another way to manage files and directories with pathlib.