Write a Python program to divide a path by the extension separator.

Write a Python program to divide a path by the extension separator.

1
2
3
4
import os.path
for path in [ 'test.txt', 'filename', '/user/system/test.txt', '/', '' ]:
    print('"%s" :' % path, os.path.splitext(path))
	

Final output

Leave a Comment