Python Example | Get Filename From a Path

This python example code shows us how to get filename from a file path.

import os

head, tail = os.path.split("/Users/xyz/Downloads")
print(head)
print(tail)

Run this code, we will get:

/Users/xyz
Downloads