os.path.split(path) は,path を (head, tail) に分割.tail はパス名の構成要素の末尾(通常はファイル名)で,head はそれより前の部分です.
import os.path path_a = 'hoge/fuga/test.txt' path_b = '../foo/bar/higa.manami' path_c = '/home/yamamoto/hiroshima' path_d = '/etc/samba/' path_e = 'host.conf' a_hd, a_tl = os.path.split(path_a) b_hd, b_tl = os.path.split(path_b) c_hd, c_tl = os.path.split(path_c) d_hd, d_tl = os.path.split(path_d) e_hd, e_tl = os.path.split(path_e) print(a_hd, '\t', a_tl) print(b_hd, '\t', b_tl) print(c_hd, '\t', c_tl) print(d_hd, '\t', d_tl) print(e_hd, '\t', e_tl)
hoge/fuga test.txt ../foo/bar higa.manami /home/yamamoto hiroshima /etc/samba host.conf