import os
fpath = "./your-directory/sub-dir/fname.jpg"
print(os.sep)
# /
basename_ext = os.path.basename(fpath)
# fname.jpg
basename = os.path.splitext(os.path.basename(fpath))[0]
# fname
extension = os.path.splitext(os.path.basename(fpath))[-1]
# .jpg
dirname = os.path.dirname(fpath)
# ./your-directory/sub-dir