Python Program to Extract Extension From the File Name (Using pathlib module)

bookmark

import pathlib
print(pathlib.Path('/path/file.ext').suffix)

 

Output

.ext