From the course: Python Theory for Network Engineers
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Lab: Working with files, file paths, and file operations - Python Tutorial
From the course: Python Theory for Network Engineers
Lab: Working with files, file paths, and file operations
- [Instructor] All right. Let's look at some file.io examples. Ever since Python 3.4 and beyond, there's been an addition of this library called pathlib that greatly reduced the complexity of finding the path of the file. If we think about it, when we need to work with a file, either reading or writing, we need to be precise with where that file is located. And it used to be a bit complex with Python, but ever since Python 3.4, they've introduced this library called pathlib that greatly reduced the complexity. And ever since 3.6, it's been included in the standard library. And that's what we're going to use for part of our example. So, the best way to learn this is through some examples and through our repo. Remember to activate your virtual environment. And we're going to go ahead and import pathlib so that we can use it. And pathlib is super easy to use. We just do Path. And if we do current working directory,…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.