Yes, there are at least two ways of doing this. The first way uses the os.path module and the second uses the pathlib module.
filename = "name.ext"
os.path.splitext returns a tuple containing the name and extension with the preceding '.' character. The code above will print out the string ".ext".
from pathlib import Path
path = Path("filename.ext")
The pathlib module contains the Path class which has many methods for interacting with file paths. The .suffix property returns the file extension with preceding period.