How to Use Python Pathlib

How to Use Python Pathlib

Python Tip: Use pathlib to work with paths.

Here is an example 👇

from pathlib import Path

path = Path('/home/user/file.txt')
print(path.parent)  # /home/user
print(path.stem)    # file
print(path.suffix)  # .txt

Subscribe to our newsletter to keep updated.

Don't miss anything. Get all the latest posts delivered straight to your inbox.
Great! Check your inbox and click the link to confirm your subscription.
Error! Please enter a valid email address!