Pathlib usage reference, pathlib reference
If any error occurs, you must specify pathlib as path3.x. It has powerful functions and is easier to operate directories. For example, you can use this module to operate directories using python3.x.
Import pathlib ----> This is just a feature used this time to facilitate memory
1. relative_to
Path1 = Path ("/home/dante ")
Path2 = Path ("/home/dante/project/src ")
Path2.relative _ to (path1) ----------> project/src remove the same part of the path1 and path2 Directories
2. glob and fnmatch
Glob is an attribute of pathlib. Path. After returning a generator loop, you can use stem (get file name), suffix (suffix, return string), and suffixes --> return list.
Fnmatch is a separate library used to filter keywords and return bool values.
3. New Features of pathlib File Reading 3.5.x
Pathlib. path ('filename'). read_text () can directly read the file.
Official documents: https://docs.python.org/3/library/pathlib.html? Highlight = read_text