How to get the filename without the extension from a path in Python?
For instance, if I had "/path/to/some/file.txt", I would want "
"/path/to/some/file.txt"
"
If you want to keep the path to the file and just remove the extension
>>> file = '/root/dir/sub.exten/file.data.1.2.dat' >>> print ('.').join(file.split('.')[:-1]) /root/dir/sub.exten/file.data.1.2