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"
"
@IceAdor's refers to rsplit in a comment to @user2902201's solution. rsplit is the simplest solution that supports multiple periods.
Here it is spelt out:
file = 'my.report.txt' print file.rsplit('.', 1)[0]
my.report