10/23/26Less than 1 minuteAbout 65 words
Concept: Stem and suffix
A path object that links to a file has a stem and a suffix. The stem is the name of the file without the suffix, and the suffix is the extension of the file.
from pathlib import Path
log_file = Path("/var/log/nginx/access.log")
print(log_file.stem) # Output: access
print(log_file.suffix) # Output: .log