Have you ever struggled with file path dealing with in Python? With the pathlib
module, the battle is now over! You not have to scratch your head over code like this:
>>> path.rsplit('', maxsplit=1)[0]
And also you don’t should cringe on the verbosity of one thing like this:
>>> os.path.isfile(os.path.be part of(os.path.expanduser('~'), 'realpython.txt'))
On this video course, you’ll learn to:
- Work with file paths in Python
- Learn and write information in new methods
- Manipulate paths and the underlying file system
- Record information and iterate over them
Utilizing the pathlib
module, the 2 examples above may be rewritten utilizing elegant, readable, and Pythonic code:
>>> path.mother or father
>>> (pathlib.Path.dwelling() / 'realpython.txt').is_file()
That’s what you’ll grasp on this video course!